aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmake/scripts/tests-win.bat3
-rw-r--r--make/scripts/tests.sh5
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java57
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelTextureStateAWT.java103
4 files changed, 106 insertions, 62 deletions
diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat
index 81eacb8c7..66f20f51b 100755
--- a/make/scripts/tests-win.bat
+++ b/make/scripts/tests-win.bat
@@ -10,7 +10,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGe
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000
-scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT %*
+REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf02AWT %*
@@ -112,6 +112,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMi
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelResize01AWT %*
+scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelTextureStateAWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.glsl.TestTransformFeedbackVaryingsBug407NEWT
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 3382e0edd..19eb6dede 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -204,7 +204,6 @@ function jrun() {
#D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.EDT -Djogamp.debug.Lock"
#D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.GraphicsConfiguration"
#D_ARGS="-Dnewt.debug.EDT"
- D_ARGS="-Dnewt.debug.Window -Dnewt.debug.EDT"
#D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext"
#D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen"
#D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window -Djogl.debug.GLJPanel -Djogl.debug.GLCanvas"
@@ -635,7 +634,7 @@ function testawtswt() {
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT $*
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $*
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $*
-#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelTextureStateAWT $*
+testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelTextureStateAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelResize01AWT $*
#testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $*
@@ -715,7 +714,7 @@ function testawtswt() {
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $*
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $*
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT $*
-testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01dAWT $*
+#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01dAWT $*
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02AWT $*
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $*
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $*
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index 21ca0c7ae..1cf0348ba 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -1692,12 +1692,40 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
if(DEBUG) {
System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: - frameCount "+frameCount);
}
+
+ final GL gl = offscreenContext.getGL();
+
+ //
+ // Save TextureState ASAP, i.e. the user values for the used FBO texture-unit
+ // and the current active texture-unit (if not same)
+ //
+ final TextureState usrTexState, fboTexState;
+ final int fboTexUnit;
+
+ if( offscreenIsFBO ) {
+ fboTexUnit = GL.GL_TEXTURE0 + ((GLFBODrawable)offscreenDrawable).getTextureUnit();
+ usrTexState = new TextureState(gl, GL.GL_TEXTURE_2D);
+ if( fboTexUnit != usrTexState.getUnit() ) {
+ // glActiveTexture(..) + glBindTexture(..) are implicit performed in GLFBODrawableImpl's
+ // swapBuffers/contextMadeCurent -> swapFBOImpl.
+ // We need to cache the texture unit's bound texture-id before it's overwritten.
+ gl.glActiveTexture(fboTexUnit);
+ fboTexState = new TextureState(gl, fboTexUnit, GL.GL_TEXTURE_2D);
+ } else {
+ fboTexState = usrTexState;
+ }
+ } else {
+ fboTexUnit = 0;
+ usrTexState = null;
+ fboTexState = null;
+ }
+
+
if( autoSwapBufferMode ) {
// Since we only use a single-buffer non-MSAA or double-buffered MSAA offscreenDrawable,
// we can always swap!
offscreenDrawable.swapBuffers();
}
- final GL gl = offscreenContext.getGL();
final int componentCount;
final int alignment;
@@ -1755,25 +1783,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
readBackInts = readBackIntsForCPUVFlip;
}
- final TextureState usrTexState, fboTexState;
- final int fboTexUnit = GL.GL_TEXTURE0 + ( offscreenIsFBO ? ((GLFBODrawable)offscreenDrawable).getTextureUnit() : 0 );
-
- if( offscreenIsFBO ) {
- usrTexState = new TextureState(gl, GL.GL_TEXTURE_2D);
- if( fboTexUnit != usrTexState.getUnit() ) {
- // glActiveTexture(..) + glBindTexture(..) are implicit performed in GLFBODrawableImpl's
- // swapBuffers/contextMadeCurent -> swapFBOImpl.
- // We need to cache the texture unit's bound texture-id before it's overwritten.
- gl.glActiveTexture(fboTexUnit);
- fboTexState = new TextureState(gl, fboTexUnit, GL.GL_TEXTURE_2D);
- } else {
- fboTexState = usrTexState;
- }
- } else {
- usrTexState = null;
- fboTexState = null;
- }
-
// Must now copy pixels from offscreen context into surface
if(DEBUG) {
System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.readPixels: - frameCount "+frameCount);
@@ -1819,7 +1828,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
if( viewportChange ) {
gl.glViewport(usrViewport[0], usrViewport[1], usrViewport[2], usrViewport[3]);
}
- fboTexState.restore(gl);
} else {
gl.glReadPixels(0, 0, panelWidth, panelHeight, pixelAttribs.format, pixelAttribs.type, readBackInts);
@@ -1839,8 +1847,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
}
}
- if( offscreenIsFBO && fboTexUnit != usrTexState.getUnit() ) {
- usrTexState.restore(gl);
+ if( 0 != fboTexUnit ) { // implies offscreenIsFBO
+ fboTexState.restore(gl);
+ if( fboTexUnit != usrTexState.getUnit() ) {
+ usrTexState.restore(gl);
+ }
}
// Restore saved modes.
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelTextureStateAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelTextureStateAWT.java
index a279870df..5a5747a59 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelTextureStateAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelTextureStateAWT.java
@@ -32,6 +32,7 @@ package com.jogamp.opengl.test.junit.jogl.awt;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureDraw02ES2ListenerFBO;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.QuitAdapter;
import com.jogamp.opengl.test.junit.util.UITestCase;
@@ -47,7 +48,6 @@ import javax.swing.JFrame;
import com.jogamp.opengl.util.texture.TextureIO;
import com.jogamp.opengl.util.texture.TextureState;
-import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.GLReadBufferUtil;
import java.awt.Dimension;
@@ -66,12 +66,27 @@ import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestGLJPanelTextureStateAWT extends UITestCase {
static boolean showFPS = false;
- static long duration = 100; // ms
+ static long duration = 250; // ms
@BeforeClass
public static void initClass() {
}
+ static void setFrameSize(final JFrame frame, final boolean frameLayout, final java.awt.Dimension new_sz) {
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setSize(new_sz);
+ if( frameLayout ) {
+ frame.validate();
+ }
+ } } );
+ } catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+ }
+
public void testImpl(final boolean keepTextureBound, final int texUnit)
throws InterruptedException, IOException
{
@@ -86,24 +101,33 @@ public class TestGLJPanelTextureStateAWT extends UITestCase {
final GLCapabilities caps = new GLCapabilities(glp);
final GLJPanel glc = new GLJPanel(caps);
- Dimension glc_sz = new Dimension(800, 400);
+ // final GLCanvas glc = new GLCanvas(caps);
+ final Dimension glc_sz = new Dimension(640, 480);
+ final Dimension glc_sz2 = new Dimension(800, 400);
glc.setMinimumSize(glc_sz);
glc.setPreferredSize(glc_sz);
final JFrame frame = new JFrame("TestGLJPanelTextureStateAWT");
Assert.assertNotNull(frame);
frame.getContentPane().add(glc);
- final TextureDraw02ES2ListenerFBO gle0;
+ final GLEventListener gle0;
{
final GearsES2 gle0sub = new GearsES2( 0 );
// gle1sub.setClearBuffers(false);
- gle0 = new TextureDraw02ES2ListenerFBO(gle0sub, 1, texUnit ) ;
+ final TextureDraw02ES2ListenerFBO demo = new TextureDraw02ES2ListenerFBO(gle0sub, 1, texUnit ) ;
+ demo.setKeepTextureBound(keepTextureBound);
+ demo.setClearBuffers(false);
+ gle0 = demo;
}
- gle0.setKeepTextureBound(keepTextureBound);
- gle0.setClearBuffers(false);
- final RedSquareES2 gle1 = new RedSquareES2( 1 ) ;
- gle1.setClearBuffers(false);
+ final GLEventListener gle1;
+ {
+ final RedSquareES2 demo = new RedSquareES2( 1 ) ;
+ demo.setClearBuffers(false);
+ gle1 = demo;
+ }
+
+ final boolean[] glelError = { false };
glc.addGLEventListener(new GLEventListener() {
int gle0X, gle0Y, gle0W, gle0H;
@@ -155,16 +179,19 @@ public class TestGLJPanelTextureStateAWT extends UITestCase {
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- // restore viewport test
- final int[] viewport = new int[] { 0, 0, 0, 0 };
- gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);
- if( gle0X != viewport[0] || gle0Y != viewport[1] || gle0W != viewport[2] || gle0H != viewport[3] ) {
- final String msg = "Expected "+viewport[0]+"/"+viewport[1]+" "+viewport[2]+"x"+viewport[3]+
- ", actual "+gle0X+"/"+gle0Y+" "+gle0W+"x"+gle0H;
- Assert.assertTrue("Viewport not restored: "+msg, false);
+ // test viewport
+ {
+ final int[] viewport = new int[] { 0, 0, 0, 0 };
+ gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);
+ if( gle1X != viewport[0] || gle1Y != viewport[1] || gle1W != viewport[2] || gle1H != viewport[3] ) {
+ final String msg = "Expected "+gle1X+"/"+gle1Y+" "+gle1W+"x"+gle1H+
+ ", actual "+viewport[0]+"/"+viewport[1]+" "+viewport[2]+"x"+viewport[3];
+ Assert.assertTrue("Viewport not restored: "+msg, false);
+ glelError[0] = true;
+ }
}
- // gl.glViewport(gle0X, gle0Y, gle0W, gle0H); // restore viewport test
+ gl.glViewport(gle0X, gle0Y, gle0W, gle0H);
gle0.display(drawable);
gl.glViewport(gle1X, gle1Y, gle1W, gle1H);
@@ -174,18 +201,19 @@ public class TestGLJPanelTextureStateAWT extends UITestCase {
if( 4 == shot ) {
gl.glViewport(tX, tY, tW, tH);
snapshot(0, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
+ gl.glViewport(gle1X, gle1Y, gle1W, gle1H); // restore viewport test
}
- gl.glViewport(gle0X, gle0Y, gle0W, gle0H); // restore viewport test
-
- final TextureState ts = new TextureState(drawable.getGL(), GL.GL_TEXTURE_2D);
+ final TextureState ts = new TextureState(drawable.getGL(), GL.GL_TEXTURE_2D); // as set via gle0!
// System.err.println("XXX: "+ts);
Assert.assertEquals("Texture unit changed", GL.GL_TEXTURE0+texUnit, ts.getUnit());
if( keepTextureBound ) {
- Assert.assertEquals("Texture mag-filter changed", GL.GL_LINEAR, ts.getMagFilter());
- Assert.assertEquals("Texture mag-filter changed", GL.GL_LINEAR, ts.getMinFilter());
- Assert.assertEquals("Texture wrap-s changed", GL.GL_REPEAT, ts.getWrapS());
- Assert.assertEquals("Texture wrap-t changed", GL.GL_REPEAT, ts.getWrapT());
+ Assert.assertEquals("Texture mag-filter changed: "+ts, GL.GL_LINEAR, ts.getMagFilter());
+ Assert.assertEquals("Texture mag-filter changed: "+ts, GL.GL_LINEAR, ts.getMinFilter());
+ Assert.assertEquals("Texture wrap-s changed: "+ts, GL.GL_REPEAT, ts.getWrapS());
+ Assert.assertEquals("Texture wrap-t changed: "+ts, GL.GL_REPEAT, ts.getWrapT());
+ glelError[0] = GL.GL_LINEAR != ts.getMagFilter() || GL.GL_LINEAR != ts.getMinFilter() ||
+ GL.GL_REPEAT != ts.getWrapS() || GL.GL_REPEAT != ts.getWrapT();
}
}
final int border = 5;
@@ -195,25 +223,26 @@ public class TestGLJPanelTextureStateAWT extends UITestCase {
gle0Y = y;
gle0W = width/2 - 2*border;
gle0H = height;
+ // System.err.println("GLEL0 "+gle0X+"/"+gle0Y+" "+gle0W+"x"+gle0H);
gle1X = gle0X + gle0W + 2*border;
gle1Y = y;
gle1W = width/2 - 2*border;
gle1H = height;
+ // System.err.println("GLEL1 "+gle1X+"/"+gle1Y+" "+gle1W+"x"+gle1H);
tX = x;
tY = y;
tW = width;
tH = height;
+ // System.err.println("Total "+tX+"/"+tY+" "+tW+"x"+tH);
GL2ES2 gl = drawable.getGL().getGL2ES2();
gl.glViewport(gle0X, gle0Y, gle0W, gle0H);
- gle0.reshape(drawable, gle0X, gle0Y, gle0W, gle0H);
+ gle0.reshape(drawable, 0, 0, gle0W, gle0H); // don't 'skip' about gle0X/gle0Y
gl.glViewport(gle1X, gle1Y, gle1W, gle1H);
- gle1.reshape(drawable, gle1X, gle1Y, gle1W, gle1H);
-
- gl.glViewport(gle0X, gle0Y, gle0W, gle0H); // restore viewport test
+ gle1.reshape(drawable, 0, 0, gle1W, gle1H); // don't 'skip' about gle0X/gle0Y
if( keepTextureBound ) {
setupTex(gl);
@@ -221,8 +250,6 @@ public class TestGLJPanelTextureStateAWT extends UITestCase {
}
});
- Animator animator = new Animator(glc);
- animator.setUpdateFPSFrames(60, showFPS ? System.err : null);
final QuitAdapter quitAdapter = new QuitAdapter();
new com.jogamp.newt.event.awt.AWTKeyAdapter(quitAdapter, glc).addTo(glc);
new com.jogamp.newt.event.awt.AWTWindowAdapter(quitAdapter, glc).addTo(glc);
@@ -236,14 +263,19 @@ public class TestGLJPanelTextureStateAWT extends UITestCase {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
}
-
- animator.start();
-
- while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
+ Assert.assertTrue("Component didn't become visible", AWTRobotUtil.waitForVisible(glc, true));
+ Assert.assertTrue("Component didn't become realized", AWTRobotUtil.waitForRealized(glc, true));
+ Thread.sleep(100);
+ setFrameSize(frame, true, glc_sz2);
+ System.err.println("window resize pos/siz: "+glc.getX()+"/"+glc.getY()+" "+glc.getSurfaceWidth()+"x"+glc.getSurfaceHeight());
+ Thread.sleep(100);
+
+ final long t0 = System.currentTimeMillis();
+ while(!quitAdapter.shouldQuit() && System.currentTimeMillis()-t0<duration) {
+ glc.display();
Thread.sleep(100);
}
- animator.stop();
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -255,6 +287,7 @@ public class TestGLJPanelTextureStateAWT extends UITestCase {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
}
+ Assume.assumeFalse("Error occured in GLEL .. see log file above", glelError[0]);
}
@Test