From aa94623ac284f57c67c16696eae111bebb7af43d Mon Sep 17 00:00:00 2001 From: codeanticode Date: Thu, 14 Jun 2012 18:29:53 +0000 Subject: [PATCH] removed quality constants from Texture --- .../processing/opengl/PGraphicsOpenGL.java | 31 +++++++------------ .../opengl/src/processing/opengl/Texture.java | 30 +++++++++--------- 2 files changed, 25 insertions(+), 36 deletions(-) diff --git a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java index 47292829a..84a536436 100644 --- a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java @@ -292,8 +292,8 @@ public class PGraphicsOpenGL extends PGraphics { // Texturing: - public int textureWrap = Texture.CLAMP; - public int textureQuality = Texture.BEST; + public int textureWrap = Texture.CLAMP; + public int textureSampling = Texture.TRILINEAR; // ........................................................ @@ -2050,13 +2050,13 @@ public class PGraphicsOpenGL extends PGraphics { public void textureWrap(int wrap) { this.textureWrap = wrap; } - - - public void textureQuality(int quality) { - this.textureQuality = quality; - } - + + public void textureSampling(int sampling) { + this.textureSampling = sampling; + } + + public void texture(PImage image) { if (flushMode == FLUSH_WHEN_FULL && hints[DISABLE_TEXTURE_CACHE] && image != textureImage0) { @@ -5256,19 +5256,10 @@ public class PGraphicsOpenGL extends PGraphics { } else { params.mipmaps = true; } - if (textureQuality == Texture.LOW) { - params.sampling = POINT; - } else if (textureQuality == Texture.MEDIUM) { - params.sampling = Texture.LINEAR; - } else if (textureQuality == Texture.HIGH) { + params.sampling = textureSampling; + if (params.sampling == Texture.TRILINEAR && !params.mipmaps) { params.sampling = Texture.BILINEAR; - } else if (textureQuality == Texture.BEST) { - if (params.mipmaps) { - params.sampling = Texture.TRILINEAR; - } else { - params.sampling = Texture.BILINEAR; - PGraphics.showWarning("BEST texture quality requires mipmaps, will switch to HIGH."); - } + PGraphics.showWarning("TRILINEAR texture sampling requires mipmaps, which are disabled. Will use BILINEAR instead."); } params.wrapU = textureWrap; params.wrapV = textureWrap; diff --git a/java/libraries/opengl/src/processing/opengl/Texture.java b/java/libraries/opengl/src/processing/opengl/Texture.java index f20717ca9..99313afb9 100644 --- a/java/libraries/opengl/src/processing/opengl/Texture.java +++ b/java/libraries/opengl/src/processing/opengl/Texture.java @@ -40,17 +40,15 @@ import java.util.NoSuchElementException; */ public class Texture implements PConstants { // texture constants - /** - * This constant identifies the texture target GL_TEXTURE_2D, that is, - * textures with normalized coordinates - */ - public static final int TEXTURE2D = 0; - /** Texture quality constants */ - public static final int LOW = 0; - public static final int MEDIUM = 1; - public static final int HIGH = 2; - public static final int BEST = 3; + /** + * Texture with normalized UV. + */ + public static final int TEX2D = 0; + /** + * Texture with un-normalized UV. + */ + public static final int TEXRECT = 1; /** Point sampling: both magnification and minification filtering are set to nearest */ //public static final int POINT = 2; // shared with shape feature @@ -1026,7 +1024,7 @@ public class Texture implements PConstants { Parameters res = new Parameters(); if (glTarget == PGL.GL_TEXTURE_2D) { - res.target = TEXTURE2D; + res.target = TEX2D; } if (glFormat == PGL.GL_RGB) { @@ -1079,7 +1077,7 @@ public class Texture implements PConstants { * @param params GLTextureParameters */ protected void setParameters(Parameters params) { - if (params.target == TEXTURE2D) { + if (params.target == TEX2D) { glTarget = PGL.GL_TEXTURE_2D; } else { throw new RuntimeException("Unknown texture target"); @@ -1179,7 +1177,7 @@ public class Texture implements PConstants { * Sets all the parameters to default values. */ public Parameters() { - this.target = TEXTURE2D; + this.target = TEX2D; this.format = ARGB; this.sampling = BILINEAR; this.mipmaps = true; @@ -1188,7 +1186,7 @@ public class Texture implements PConstants { } public Parameters(int format) { - this.target = TEXTURE2D; + this.target = TEX2D; this.format = format; this.sampling = BILINEAR; this.mipmaps = true; @@ -1197,7 +1195,7 @@ public class Texture implements PConstants { } public Parameters(int format, int sampling) { - this.target = TEXTURE2D; + this.target = TEX2D; this.format = format; this.sampling = sampling; this.mipmaps = true; @@ -1206,7 +1204,7 @@ public class Texture implements PConstants { } public Parameters(int format, int sampling, boolean mipmaps) { - this.target = TEXTURE2D; + this.target = TEX2D; this.format = format; this.sampling = sampling; this.mipmaps = mipmaps;