diff options
author | Sven Gothel <[email protected]> | 2013-03-09 04:23:55 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-03-09 04:23:55 +0100 |
commit | d3672684177a98a58c434bcd27541f44917050f3 (patch) | |
tree | d4f7fd36cc1178172b1524bc3e1cd2ec3d7ac383 /src/test | |
parent | b29f221c903aefdf99af8e8a8544b2223036454f (diff) |
Fix Mix2TexturesES2 unit tests: Use synchronized texID access and add glFinish() after demo -> FBO rendering on or off thread.
Fixes shared GLContext OSX rendering.
Diffstat (limited to 'src/test')
4 files changed, 67 insertions, 15 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java index 3ecf89bfc..19e57c9bc 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java @@ -44,6 +44,7 @@ import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.FPSAnimator; import com.jogamp.opengl.util.GLReadBufferUtil; import com.jogamp.opengl.util.texture.TextureIO; +import com.jogamp.opengl.test.junit.jogl.demos.GLFinishOnDisplay; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.jogl.demos.es2.Mix2TexturesES2; import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; @@ -136,6 +137,7 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { { GearsES2 demo0 = new GearsES2(-1); fbod1.addGLEventListener(demo0); + fbod1.addGLEventListener(new GLFinishOnDisplay()); demo0.setIgnoreFocus(true); } fbod1.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() { @@ -152,6 +154,7 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext()); fbod2.setTextureUnit(fbod2_texUnit); fbod2.addGLEventListener(new RedSquareES2(-1)); + fbod2.addGLEventListener(new GLFinishOnDisplay()); fbod2.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() { @Override public void surfaceUpdated(Object updater, NativeSurface ns, long when) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java index 7d9a9c662..acd46f57f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java @@ -43,6 +43,7 @@ import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLReadBufferUtil; import com.jogamp.opengl.util.texture.TextureIO; +import com.jogamp.opengl.test.junit.jogl.demos.GLFinishOnDisplay; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.jogl.demos.es2.Mix2TexturesES2; @@ -133,6 +134,7 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase { { GearsES2 demo0 = new GearsES2(-1); fbod1.addGLEventListener(demo0); + fbod1.addGLEventListener(new GLFinishOnDisplay()); demo0.setIgnoreFocus(true); } fbod1.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/GLFinishOnDisplay.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/GLFinishOnDisplay.java new file mode 100644 index 000000000..cb76f1057 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/GLFinishOnDisplay.java @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2013 JogAmp Community. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.jogamp.opengl.test.junit.jogl.demos; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; + +public class GLFinishOnDisplay implements GLEventListener { + @Override + public void init(GLAutoDrawable drawable) { } + + @Override + public void dispose(GLAutoDrawable drawable) { } + + @Override + public void display(GLAutoDrawable drawable) { + drawable.getGL().glFinish(); + } + + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java index 26e7e234a..cd40b5c6e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java @@ -42,7 +42,8 @@ public class Mix2TexturesES2 implements GLEventListener { private final PMVMatrix pmvMatrix; private final GLUniformData texUnit0, texUnit1; - private volatile int texID0, texID1; + private Object syncTexIDs = new Object(); + private int texID0, texID1; private ShaderProgram sp0; private GLUniformData pmvMatrixUniform; private GLArrayDataServer interleavedVBO; @@ -66,10 +67,14 @@ public class Mix2TexturesES2 implements GLEventListener { } public void setTexID0(int texID) { - this.texID0 = texID; + synchronized( syncTexIDs ) { + this.texID0 = texID; + } } public void setTexID1(int texID) { - this.texID1 = texID; + synchronized( syncTexIDs ) { + this.texID1 = texID; + } } static final String[] es2_prelude = { "#version 100\n", "precision mediump float;\n" }; @@ -156,20 +161,22 @@ public class Mix2TexturesES2 implements GLEventListener { interleavedVBO.enableBuffer(gl, true); - if(0<texID0) { - gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit0.intValue()); - gl.glBindTexture(GL.GL_TEXTURE_2D, texID0); - } - - if(0<texID1 && null != texUnit1) { - gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit1.intValue()); - gl.glBindTexture(GL.GL_TEXTURE_2D, texID1); + synchronized( syncTexIDs ) { + if(0<texID0) { + gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit0.intValue()); + gl.glBindTexture(GL.GL_TEXTURE_2D, texID0); + } + + if(0<texID1 && null != texUnit1) { + gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit1.intValue()); + gl.glBindTexture(GL.GL_TEXTURE_2D, texID1); + } + + gl.glEnable(GL.GL_TEXTURE_2D); + + gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4); } - gl.glEnable(GL.GL_TEXTURE_2D); - - gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4); - interleavedVBO.enableBuffer(gl, false); st.useProgram(gl, false); |