From 083ab11af974188dffeb25bc944c2ec90f912fe9 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Fri, 20 Jul 2012 18:00:32 +0000 Subject: [PATCH] fixed texture unbind error --- android/core/src/processing/opengl/Texture.java | 10 +++------- .../opengl/src/processing/opengl/Texture.java | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/android/core/src/processing/opengl/Texture.java b/android/core/src/processing/opengl/Texture.java index 0039f4e66..5d05dc9c2 100644 --- a/android/core/src/processing/opengl/Texture.java +++ b/android/core/src/processing/opengl/Texture.java @@ -294,7 +294,7 @@ public class Texture implements PConstants { // Automatic mipmap generation. int[] rgbaPixels = new int[w * h]; convertToRGBA(pixels, rgbaPixels, format, w, h); - setNative(rgbaPixels, x, y, w, h); + pgl.glTexSubImage2D(glTarget, 0, x, y, w, h, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, IntBuffer.wrap(rgbaPixels)); pgl.glGenerateMipmap(glTarget); rgbaPixels = null; } else { @@ -354,13 +354,13 @@ public class Texture implements PConstants { int[] rgbaPixels = new int[w * h]; convertToRGBA(pixels, rgbaPixels, format, w, h); - setNative(rgbaPixels, x, y, w, h); + pgl.glTexSubImage2D(glTarget, 0, x, y, w, h, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, IntBuffer.wrap(rgbaPixels)); rgbaPixels = null; } } else { int[] rgbaPixels = new int[w * h]; convertToRGBA(pixels, rgbaPixels, format, w, h); - setNative(rgbaPixels, x, y, w, h); + pgl.glTexSubImage2D(glTarget, 0, x, y, w, h, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, IntBuffer.wrap(rgbaPixels)); rgbaPixels = null; } @@ -704,9 +704,7 @@ public class Texture implements PConstants { if ((data.w != width) || (data.h != height)) { init(data.w, data.h); } - bind(); setNative(data.rgbBuf, 0, 0, width, height); - unbind(); data.dispose(); @@ -729,9 +727,7 @@ public class Texture implements PConstants { if ((data.w != width) || (data.h != height)) { init(data.w, data.h); } - bind(); setNative(data.rgbBuf, 0, 0, width, height); - unbind(); data.rgbBuf.get(pixels); convertToARGB(pixels); diff --git a/java/libraries/opengl/src/processing/opengl/Texture.java b/java/libraries/opengl/src/processing/opengl/Texture.java index 0039f4e66..5d05dc9c2 100644 --- a/java/libraries/opengl/src/processing/opengl/Texture.java +++ b/java/libraries/opengl/src/processing/opengl/Texture.java @@ -294,7 +294,7 @@ public class Texture implements PConstants { // Automatic mipmap generation. int[] rgbaPixels = new int[w * h]; convertToRGBA(pixels, rgbaPixels, format, w, h); - setNative(rgbaPixels, x, y, w, h); + pgl.glTexSubImage2D(glTarget, 0, x, y, w, h, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, IntBuffer.wrap(rgbaPixels)); pgl.glGenerateMipmap(glTarget); rgbaPixels = null; } else { @@ -354,13 +354,13 @@ public class Texture implements PConstants { int[] rgbaPixels = new int[w * h]; convertToRGBA(pixels, rgbaPixels, format, w, h); - setNative(rgbaPixels, x, y, w, h); + pgl.glTexSubImage2D(glTarget, 0, x, y, w, h, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, IntBuffer.wrap(rgbaPixels)); rgbaPixels = null; } } else { int[] rgbaPixels = new int[w * h]; convertToRGBA(pixels, rgbaPixels, format, w, h); - setNative(rgbaPixels, x, y, w, h); + pgl.glTexSubImage2D(glTarget, 0, x, y, w, h, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, IntBuffer.wrap(rgbaPixels)); rgbaPixels = null; } @@ -704,9 +704,7 @@ public class Texture implements PConstants { if ((data.w != width) || (data.h != height)) { init(data.w, data.h); } - bind(); setNative(data.rgbBuf, 0, 0, width, height); - unbind(); data.dispose(); @@ -729,9 +727,7 @@ public class Texture implements PConstants { if ((data.w != width) || (data.h != height)) { init(data.w, data.h); } - bind(); setNative(data.rgbBuf, 0, 0, width, height); - unbind(); data.rgbBuf.get(pixels); convertToARGB(pixels);