From e02e3392c0ff31f1d95b98fb62808a07fdb80f10 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Mon, 19 Nov 2012 16:54:11 +0000 Subject: [PATCH] don't enable mipmapping if texture is the color buffer of a PGraphics --- .../core/src/processing/opengl/PGraphicsOpenGL.java | 4 +++- android/core/src/processing/opengl/Texture.java | 13 +++++++++++++ core/src/processing/opengl/PGraphicsOpenGL.java | 4 +++- core/src/processing/opengl/Texture.java | 13 +++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/android/core/src/processing/opengl/PGraphicsOpenGL.java b/android/core/src/processing/opengl/PGraphicsOpenGL.java index 43594fe00..8e7c27d47 100644 --- a/android/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/android/core/src/processing/opengl/PGraphicsOpenGL.java @@ -5522,6 +5522,7 @@ public class PGraphicsOpenGL extends PGraphics { sampling, mipmap); texture = new Texture(parent, width, height, params); texture.invertedY(true); + texture.colorBufferOf(this); pgPrimary.setCache(this, texture); } } @@ -5970,7 +5971,8 @@ public class PGraphicsOpenGL extends PGraphics { protected void checkTexture(Texture tex) { - if (tex.usingMipmaps == hints[DISABLE_TEXTURE_MIPMAPS]) { + if (!tex.isColorBuffer() && + tex.usingMipmaps == hints[DISABLE_TEXTURE_MIPMAPS]) { if (hints[DISABLE_TEXTURE_MIPMAPS]) { tex.usingMipmaps(false, textureSampling); } else { diff --git a/android/core/src/processing/opengl/Texture.java b/android/core/src/processing/opengl/Texture.java index 6e3d05a97..669769aea 100644 --- a/android/core/src/processing/opengl/Texture.java +++ b/android/core/src/processing/opengl/Texture.java @@ -82,6 +82,7 @@ public class Texture implements PConstants { protected PGraphicsOpenGL pg; // The main renderer protected PGL pgl; // The interface between Processing and OpenGL. protected PGL.Context context; // The context that created this texture. + protected PGraphicsOpenGL pgDraw; // The main renderer is the color buffer of. protected boolean usingMipmaps; protected boolean usingRepeat; @@ -135,6 +136,8 @@ public class Texture implements PConstants { pgl = pg.pgl; context = pgl.createEmptyContext(); + pgDraw = null; + glName = 0; init(width, height, (Parameters)params); @@ -1184,6 +1187,16 @@ public class Texture implements PConstants { } + protected void colorBufferOf(PGraphicsOpenGL pgDraw) { + this.pgDraw = pgDraw; + } + + + protected boolean isColorBuffer() { + return pgDraw != null; + } + + /////////////////////////////////////////////////////////// // Utilities. diff --git a/core/src/processing/opengl/PGraphicsOpenGL.java b/core/src/processing/opengl/PGraphicsOpenGL.java index b44d0f6a6..071341e80 100644 --- a/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/core/src/processing/opengl/PGraphicsOpenGL.java @@ -5530,6 +5530,7 @@ public class PGraphicsOpenGL extends PGraphics { sampling, mipmap); texture = new Texture(parent, width, height, params); texture.invertedY(true); + texture.colorBufferOf(this); pgPrimary.setCache(this, texture); } } @@ -5978,7 +5979,8 @@ public class PGraphicsOpenGL extends PGraphics { protected void checkTexture(Texture tex) { - if (tex.usingMipmaps == hints[DISABLE_TEXTURE_MIPMAPS]) { + if (!tex.isColorBuffer() && + tex.usingMipmaps == hints[DISABLE_TEXTURE_MIPMAPS]) { if (hints[DISABLE_TEXTURE_MIPMAPS]) { tex.usingMipmaps(false, textureSampling); } else { diff --git a/core/src/processing/opengl/Texture.java b/core/src/processing/opengl/Texture.java index 510e35832..67a55aca2 100644 --- a/core/src/processing/opengl/Texture.java +++ b/core/src/processing/opengl/Texture.java @@ -82,6 +82,7 @@ public class Texture implements PConstants { protected PGraphicsOpenGL pg; // The main renderer protected PGL pgl; // The interface between Processing and OpenGL. protected PGL.Context context; // The context that created this texture. + protected PGraphicsOpenGL pgDraw; // The main renderer is the color buffer of. protected boolean usingMipmaps; protected boolean usingRepeat; @@ -135,6 +136,8 @@ public class Texture implements PConstants { pgl = pg.pgl; context = pgl.createEmptyContext(); + pgDraw = null; + glName = 0; init(width, height, (Parameters)params); @@ -1184,6 +1187,16 @@ public class Texture implements PConstants { } + protected void colorBufferOf(PGraphicsOpenGL pgDraw) { + this.pgDraw = pgDraw; + } + + + protected boolean isColorBuffer() { + return pgDraw != null; + } + + /////////////////////////////////////////////////////////// // Utilities.