From aa2fe6ccf17d514b7a1a7844d9243ca6db614a22 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Thu, 23 Jan 2014 13:09:31 -0500 Subject: [PATCH] make sure to recreate texture rendering VBO when context changes, fix #2322 --- core/src/processing/opengl/PGL.java | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/core/src/processing/opengl/PGL.java b/core/src/processing/opengl/PGL.java index 96c4fcb7d..3e8d0592f 100644 --- a/core/src/processing/opengl/PGL.java +++ b/core/src/processing/opengl/PGL.java @@ -166,6 +166,7 @@ public abstract class PGL { protected int tex2DVertLoc; protected int tex2DTCoordLoc; protected int tex2DSamplerLoc; + protected int tex2DGeoVBO; protected boolean loadedTexRectShader = false; protected int texRectShaderProgram; @@ -175,8 +176,7 @@ public abstract class PGL { protected int texRectVertLoc; protected int texRectTCoordLoc; protected int texRectSamplerLoc; - - protected int texGeoVBO; + protected int texRectGeoVBO; protected float[] texCoords = { // X, Y, U, V @@ -929,12 +929,10 @@ public abstract class PGL { ppgl.loadedTex2DShader = true; ppgl.tex2DShaderContext = ppgl.glContext; - if (ppgl.texGeoVBO == 0) { - genBuffers(1, intBuffer); - ppgl.texGeoVBO = intBuffer.get(0); - bindBuffer(ARRAY_BUFFER, ppgl.texGeoVBO); - bufferData(ARRAY_BUFFER, 16 * SIZEOF_FLOAT, null, STATIC_DRAW); - } + genBuffers(1, intBuffer); + ppgl.tex2DGeoVBO = intBuffer.get(0); + bindBuffer(ARRAY_BUFFER, ppgl.tex2DGeoVBO); + bufferData(ARRAY_BUFFER, 16 * SIZEOF_FLOAT, null, STATIC_DRAW); } if (texData == null) { @@ -1008,7 +1006,7 @@ public abstract class PGL { uniform1i(ppgl.tex2DSamplerLoc, 0); texData.position(0); - bindBuffer(ARRAY_BUFFER, ppgl.texGeoVBO); + bindBuffer(ARRAY_BUFFER, ppgl.tex2DGeoVBO); bufferData(ARRAY_BUFFER, 16 * SIZEOF_FLOAT, texData, STATIC_DRAW); vertexAttribPointer(ppgl.tex2DVertLoc, 2, FLOAT, false, 4 * SIZEOF_FLOAT, 0); @@ -1061,12 +1059,10 @@ public abstract class PGL { ppgl.loadedTexRectShader = true; ppgl.texRectShaderContext = ppgl.glContext; - if (ppgl.texGeoVBO == 0) { - genBuffers(1, intBuffer); - ppgl.texGeoVBO = intBuffer.get(0); - bindBuffer(ARRAY_BUFFER, ppgl.texGeoVBO); - bufferData(ARRAY_BUFFER, 16 * SIZEOF_FLOAT, null, STATIC_DRAW); - } + genBuffers(1, intBuffer); + ppgl.texRectGeoVBO = intBuffer.get(0); + bindBuffer(ARRAY_BUFFER, ppgl.texRectGeoVBO); + bufferData(ARRAY_BUFFER, 16 * SIZEOF_FLOAT, null, STATIC_DRAW); } return ppgl; @@ -1140,7 +1136,7 @@ public abstract class PGL { uniform1i(ppgl.texRectSamplerLoc, 0); texData.position(0); - bindBuffer(ARRAY_BUFFER, ppgl.texGeoVBO); + bindBuffer(ARRAY_BUFFER, ppgl.texRectGeoVBO); bufferData(ARRAY_BUFFER, 16 * SIZEOF_FLOAT, texData, STATIC_DRAW); vertexAttribPointer(ppgl.texRectVertLoc, 2, FLOAT, false, 4 * SIZEOF_FLOAT, 0);