diff options
author | Sven Gothel <[email protected]> | 2014-06-09 16:42:33 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-06-09 16:42:33 +0200 |
commit | 99230cc04b6d0143088129ccc1a20d5c8799ca67 (patch) | |
tree | ce61b5f4b8e62d4d2372f6e4824a98c38f0a8982 /src | |
parent | 4686a652d821efe04045333026be79270bc19bfd (diff) |
GraphUI: Fix using multiple texture units w/ opt. colorTexUnit in GLRegion
The texture unit has to be updated always,
since program maybe used by multiple regions and diff. texUnits
Diffstat (limited to 'src')
4 files changed, 21 insertions, 18 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java index d870644f3..a9aa8cfb0 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java @@ -515,11 +515,8 @@ public class VBORegion2PMSAAES2 extends GLRegion { final Texture tex = frame.getTexture(); tex.bind(gl); tex.enable(gl); // nop on core - final int colorTexUnit = colorTexSeq.getTextureUnit(); - if( colorTexUnit != gcu_ColorTexUnit.intValue() ) { - gcu_ColorTexUnit.setData(colorTexUnit); - gl.glUniform(gcu_ColorTexUnit); - } + gcu_ColorTexUnit.setData(colorTexSeq.getTextureUnit()); + gl.glUniform(gcu_ColorTexUnit); // Always update, since program maybe used by multiple regions gl.glUniform(gcu_ColorTexBBox); // Always update, since program maybe used by multiple regions gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL2ES2.GL_UNSIGNED_SHORT, 0); tex.disable(gl); // nop on core diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java index cea292210..68a7b6dbd 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java @@ -634,11 +634,8 @@ public class VBORegion2PVBAAES2 extends GLRegion { final Texture tex = frame.getTexture(); tex.bind(gl); tex.enable(gl); // nop on core - final int colorTexUnit = colorTexSeq.getTextureUnit(); - if( colorTexUnit != gcu_ColorTexUnit.intValue() ) { - gcu_ColorTexUnit.setData(colorTexUnit); - gl.glUniform(gcu_ColorTexUnit); - } + gcu_ColorTexUnit.setData(colorTexSeq.getTextureUnit()); + gl.glUniform(gcu_ColorTexUnit); // Always update, since program maybe used by multiple regions gl.glUniform(gcu_ColorTexBBox); // Always update, since program maybe used by multiple regions gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL2ES2.GL_UNSIGNED_SHORT, 0); tex.disable(gl); // nop on core diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java index 24d53c1a2..8265b014a 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java @@ -241,12 +241,9 @@ public class VBORegionSPES2 extends GLRegion { final Texture tex = frame.getTexture(); tex.bind(gl); tex.enable(gl); // nop on core - final int colorTexUnit = colorTexSeq.getTextureUnit(); - if( colorTexUnit != gcu_ColorTexUnit.intValue() ) { - gcu_ColorTexUnit.setData(colorTexUnit); - gl.glUniform(gcu_ColorTexUnit); - } - gl.glUniform(gcu_ColorTexBBox); // FIXME: Only if changed! + gcu_ColorTexUnit.setData(colorTexSeq.getTextureUnit()); + gl.glUniform(gcu_ColorTexUnit); // Always update, since program maybe used by multiple regions + gl.glUniform(gcu_ColorTexBBox); // Always update, since program maybe used by multiple regions gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL2ES2.GL_UNSIGNED_SHORT, 0); tex.disable(gl); // nop on core } else { diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java index fbb29d6ea..e58051131 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java @@ -509,9 +509,21 @@ public class GPUUISceneGLListener0A implements GLEventListener { final float button2XSize = 2f*buttonXSize; final float button2YSize = 2f*buttonYSize; final float xStartRight = -button2XSize - 8f; // aligned to right edge via reshape + final int texUnitMediaPlayer, texUnitImageButton, texUnitGLELButton; + if( true ) { + texUnitMediaPlayer=0; + texUnitImageButton=0; + texUnitGLELButton=0; + } else { + // works - but not required .. + texUnitMediaPlayer=1; + texUnitImageButton=2; + texUnitGLELButton=3; + } if(true) { final GLMediaPlayer mPlayer = GLMediaPlayerFactory.createDefault(); + mPlayer.setTextureUnit(texUnitMediaPlayer); final MediaPlayerButton mPlayerButton = new MediaPlayerButton(renderer.getRenderState().getVertexFactory(), renderModes, button2XSize, button2YSize, mPlayer); mPlayerButton.addDefaultEventListener(); @@ -534,7 +546,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { } } if( true ) { - final ImageSequence imgSeq = new ImageSequence(0, true); + final ImageSequence imgSeq = new ImageSequence(texUnitImageButton, true); final ImageSeqButton imgButton = new ImageSeqButton(renderer.getRenderState().getVertexFactory(), renderModes, button2XSize, button2YSize, imgSeq); try { @@ -564,7 +576,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { glel.setClearColor(new float[] { 0.9f, 0.9f, 0.9f, 1f } ); final GLEventListenerButton glelButton = new GLEventListenerButton(renderer.getRenderState().getVertexFactory(), renderModes, button2XSize, button2YSize, - 0, glel, false /* useAlpha */, + texUnitGLELButton, glel, false /* useAlpha */, (int)(button2XSize), (int)(button2YSize)); glelButton.setToggleable(true); glelButton.setToggle(true); // toggle == true -> animation |