summaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-08-27 13:15:44 +0200
committerSven Gothel <[email protected]>2015-08-27 13:15:44 +0200
commitdeff49c901915e007f43a1df1a0d217a786e9f06 (patch)
tree46b5c4ed38772c1f5d32498904da9318b3ecab83 /src/test/com/jogamp/opengl
parent8b4f68a3a014c3ae62a64def3011ccc43e8c41c9 (diff)
Bug 1202 - Add support of Adaptive Vsync via [GLX|WGL]_EXT_swap_control_tear
[GLX|WGL]_EXT_swap_control_tear extensions support asynchronous buffer swaps, i.e. adaptive Vsync. <https://www.opengl.org/wiki/SwapInterval_aka_vsync#Adaptive_Vsync> <https://www.opengl.org/registry/specs/EXT/wgl_swap_control_tear.txt> <https://www.opengl.org/registry/specs/EXT/glx_swap_control_tear.txt> <http://keithp.com/blogs/async_flip/> The extensions utilizes a negative interval value, enabling late swaps to occur without synchronization to the video frame. Hence '-1' has new semantics, previously it was the 'default value' of 'untouched vsync interval'. New default is: - 0 for unrealized context - 1 for realized context +++ It requires [GLX|WGL]_EXT_swap_control, hence we shall ensure to use use this extension in the implementation of GLContext.setSwapInterval(..). +++ Mesa3D seems to support GLX_SGI_swap_control only. +++ Implemented on Windows and X11. +++ On GNU/Linux using NVidia driver w/ my setup(*), sadly the query GLX.glXQueryDrawable(displayHandle, drawable.getHandle(), GLX.GLX_LATE_SWAPS_TEAR_EXT, val); always returns zero here, indicating async vsync is not supported. (Queried the attribute for every frame in windowed or fullscreen mode) Fullscreen (*) - Debian 8 - Kernel 3.16 - KDE/Kwin - GL Version 4.5 (Core profile, arb, compat[ES2, ES3, ES31], FBO, hardware) - 4.5.0 NVIDIA 355.06 [GL 4.5.0, vendor 355.6.0 (NVIDIA 355.06)] - GL_RENDERER GeForce GTX 660/PCIe/SSE2 - Samsung U28D590 (DFP-4): Internal DisplayPort +++
Diffstat (limited to 'src/test/com/jogamp/opengl')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java7
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java13
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java18
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/PointsDemoES1.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LandscapeES2.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareMappedES2.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java27
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java25
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/NEWTDemoListener.java75
17 files changed, 125 insertions, 84 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java
index 86b129fe1..36e263f78 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java
@@ -54,6 +54,7 @@ import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.FontFactory;
import com.jogamp.graph.geom.SVertex;
+import com.jogamp.junit.util.JunitTracer;
import com.jogamp.newt.Window;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.util.MiscUtils;
@@ -73,7 +74,7 @@ public class TestTextRendererNEWT00 extends UITestCase {
static int GraphVBAASamples = 0;
static int GraphMSAASamples = 0;
static boolean ManualTest = false;
- static int SwapInterval = 0;
+ static int SwapInterval = 1;
static String fontFileName = null;
static URL fontURL = null;
@@ -213,7 +214,7 @@ public class TestTextRendererNEWT00 extends UITestCase {
window.display();
System.err.println("Chosen: "+window.getChosenGLCapabilities());
if( WaitStartEnd ) {
- UITestCase.waitForKey("Start");
+ JunitTracer.waitForKey("Start");
}
final RenderState rs = RenderState.createRenderState(SVertex.factory());
@@ -252,7 +253,7 @@ public class TestTextRendererNEWT00 extends UITestCase {
});
anim.stop();
if( WaitStartEnd ) {
- UITestCase.waitForKey("Stop");
+ JunitTracer.waitForKey("Stop");
}
destroyWindow(window);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java
index 73b76debb..b26ed88a8 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java
@@ -302,9 +302,16 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
@Override
public boolean run(final GLAutoDrawable drawable) {
final GL gl = drawable.getGL();
- int i = gl.getSwapInterval();
- i = i==0 ? 1 : 0;
+ final int _i = gl.getSwapInterval();
+ final int i;
+ switch(_i) {
+ case 0: i = -1; break;
+ case -1: i = 1; break;
+ case 1: i = 0; break;
+ default: i = 1; break;
+ }
gl.setSwapInterval(i);
+
final GLAnimatorControl a = drawable.getAnimator();
if( null != a ) {
a.resetFPSCounter();
@@ -312,7 +319,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
if(drawable instanceof FPSCounter) {
((FPSCounter)drawable).resetFPSCounter();
}
- System.err.println("Swap Interval: "+i);
+ System.err.println("Swap Interval: "+_i+" -> "+i+" -> "+gl.getSwapInterval());
return true;
}
});
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java
index 2e3d2fac3..ab5bfb926 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java
@@ -32,6 +32,7 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
+import com.jogamp.opengl.FPSCounter;
import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL2ES2;
import com.jogamp.opengl.GLAnimatorControl;
@@ -285,16 +286,27 @@ public abstract class UIListenerBase01 implements GLEventListener {
else if(arg0.getKeyCode() == KeyEvent.VK_V) {
if(null != autoDrawable) {
autoDrawable.invoke(false, new GLRunnable() {
+ @Override
public boolean run(final GLAutoDrawable drawable) {
final GL gl = drawable.getGL();
- int i = gl.getSwapInterval();
- i = i==0 ? 1 : 0;
+ final int _i = gl.getSwapInterval();
+ final int i;
+ switch(_i) {
+ case 0: i = 1; break;
+ case 1: i = -1; break;
+ case -1: i = 0; break;
+ default: i = 1; break;
+ }
gl.setSwapInterval(i);
+
final GLAnimatorControl a = drawable.getAnimator();
if( null != a ) {
a.resetFPSCounter();
}
- System.err.println("Swap Interval: "+i);
+ if(drawable instanceof FPSCounter) {
+ ((FPSCounter)drawable).resetFPSCounter();
+ }
+ System.err.println("Swap Interval: "+_i+" -> "+i+" -> "+gl.getSwapInterval());
return true;
}
});
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/PointsDemoES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/PointsDemoES1.java
index 7189db1f3..e8acb0baf 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/PointsDemoES1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/PointsDemoES1.java
@@ -181,9 +181,7 @@ public class PointsDemoES1 extends PointsDemo {
// Thread.dumpStack();
final GL2ES1 gl = glad.getGL().getGL2ES1();
- if(-1 != swapInterval) {
- gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
- }
+ gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
// Set location in front of camera
gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java
index 60ac6b233..7eebf4489 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java
@@ -141,9 +141,7 @@ public class RedSquareES1 implements GLEventListener, TileRendererBase.TileRende
@Override
public void reshape(final GLAutoDrawable glad, final int x, final int y, final int width, final int height) {
final GL2ES1 gl = glad.getGL().getGL2ES1();
- if(-1 != swapInterval) {
- gl.setSwapInterval(swapInterval);
- }
+ gl.setSwapInterval(swapInterval);
reshapeImpl(gl, x, y, width, height, width, height);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java
index ff88af50a..de2d3458a 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java
@@ -267,9 +267,7 @@ public class FBOMix2DemosES2 implements GLEventListener {
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
- if(-1 != swapInterval) {
- gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
- }
+ gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
System.err.println("**** Reshape: "+width+"x"+height);
resetFBOs(gl, drawable);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
index e1abcc752..c0a4756e7 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
@@ -319,9 +319,7 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen
public void reshape(final GLAutoDrawable glad, final int x, final int y, final int width, final int height) {
if( !isInit ) { return; }
final GL2ES2 gl = glad.getGL().getGL2ES2();
- if(-1 != swapInterval) {
- gl.setSwapInterval(swapInterval);
- }
+ gl.setSwapInterval(swapInterval);
reshapeImpl(gl, x, y, width, height, width, height);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LandscapeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LandscapeES2.java
index a504ec1ed..18c0ffd68 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LandscapeES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LandscapeES2.java
@@ -128,9 +128,7 @@ public class LandscapeES2 implements GLEventListener {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
- if(-1 != swapInterval) {
- gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
- }
+ gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
shaderState.useProgram(gl, true);
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 6d202707e..3ec383ad8 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
@@ -181,9 +181,7 @@ public class Mix2TexturesES2 implements GLEventListener {
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
- if(-1 != swapInterval) {
- gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
- }
+ gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
pmvMatrix.glLoadIdentity();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java
index 673552c5f..d59c1bb84 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java
@@ -186,9 +186,7 @@ public class PointsDemoES2 extends PointsDemo {
// Thread.dumpStack();
final GL2ES2 gl = glad.getGL().getGL2ES2();
- if(-1 != swapInterval) {
- gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
- }
+ gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
st.useProgram(gl, true);
// Set location in front of camera
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
index a0afef87a..4da4b7c01 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
@@ -192,9 +192,7 @@ public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRende
@Override
public void reshape(final GLAutoDrawable glad, final int x, final int y, final int width, final int height) {
final GL2ES2 gl = glad.getGL().getGL2ES2();
- if(-1 != swapInterval) {
- gl.setSwapInterval(swapInterval);
- }
+ gl.setSwapInterval(swapInterval);
reshapeImpl(gl, x, y, width, height, width, height);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareMappedES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareMappedES2.java
index 9dab97d16..3b526401d 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareMappedES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareMappedES2.java
@@ -211,9 +211,7 @@ public class RedSquareMappedES2 implements GLEventListener, TileRendererBase.Til
@Override
public void reshape(final GLAutoDrawable glad, final int x, final int y, final int width, final int height) {
final GL2ES2 gl = glad.getGL().getGL2ES2();
- if(-1 != swapInterval) {
- gl.setSwapInterval(swapInterval);
- }
+ gl.setSwapInterval(swapInterval);
reshapeImpl(gl, x, y, width, height, width, height);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java
index 2d6745594..e360b5987 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java
@@ -230,9 +230,7 @@ public class TextureDraw02ES2ListenerFBO implements GLEventListener {
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
- if(-1 != swapInterval) {
- gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
- }
+ gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
System.err.println("**** Reshape.Reset: "+width+"x"+height);
if( keepTextureBound ) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java
index b938adb53..525995122 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java
@@ -46,6 +46,7 @@ import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.font.Font;
+import com.jogamp.junit.util.JunitTracer;
import com.jogamp.newt.Window;
import com.jogamp.newt.event.KeyAdapter;
import com.jogamp.newt.event.KeyEvent;
@@ -57,7 +58,6 @@ import com.jogamp.opengl.JoglVersion;
import com.jogamp.opengl.test.junit.graph.TextRendererGLELBase;
import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureSequenceCubeES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
-import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.av.GLMediaPlayer;
import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener;
@@ -75,7 +75,7 @@ public class MovieCube implements GLEventListener {
private TextureSequenceCubeES2 cube=null;
private GLMediaPlayer mPlayer=null;
private int swapInterval = 1;
- private int swapIntervalSet = -1;
+ private boolean swapIntervalSet = true;
private long lastPerfPos = 0;
private volatile boolean resetGLState = false;
@@ -246,7 +246,7 @@ public class MovieCube implements GLEventListener {
final String text1 = String.format("%0"+ptsPrec+"f/%0"+ptsPrec+"f s, %s (%01.2fx, vol %01.2f), a %01.2f, fps %02.1f -> %02.1f / %02.1f, v-sync %d",
pts, mPlayer.getDuration() / 1000f,
mPlayer.getState().toString().toLowerCase(), mPlayer.getPlaySpeed(), mPlayer.getAudioVolume(),
- aspect, mPlayer.getFramerate(), lfps, tfps, swapIntervalSet);
+ aspect, mPlayer.getFramerate(), lfps, tfps, swapInterval);
final String text2 = String.format("audio: id %d, kbps %d, codec %s",
mPlayer.getAID(), mPlayer.getAudioBitrate()/1000, mPlayer.getAudioCodec());
final String text3 = String.format("video: id %d, kbps %d, codec %s",
@@ -278,10 +278,13 @@ public class MovieCube implements GLEventListener {
int pts1 = 0;
switch(e.getKeySymbol()) {
case KeyEvent.VK_V: {
- switch(swapIntervalSet) {
- case 0: swapInterval = 1; break;
- default: swapInterval = 0; break;
+ switch(swapInterval) {
+ case 0: swapInterval = -1; break;
+ case -1: swapInterval = 1; break;
+ case 1: swapInterval = 0; break;
+ default: swapInterval = 1; break;
}
+ swapIntervalSet = true;
break;
}
case KeyEvent.VK_O: displayOSD = !displayOSD; break;
@@ -362,7 +365,7 @@ public class MovieCube implements GLEventListener {
cube = new TextureSequenceCubeES2(mPlayer, false, zoom0, rotx, roty);
if(waitForKey) {
- UITestCase.waitForKey("Init>");
+ JunitTracer.waitForKey("Init>");
}
if( GLMediaPlayer.State.Initialized == mPlayer.getState() ) {
@@ -433,12 +436,14 @@ public class MovieCube implements GLEventListener {
@Override
public void display(final GLAutoDrawable drawable) {
- if(-1 != swapInterval) {
+ if( swapIntervalSet ) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
- gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
+ final int _swapInterval = swapInterval;
+ gl.setSwapInterval(_swapInterval); // in case switching the drawable (impl. may bound attribute there)
drawable.getAnimator().resetFPSCounter();
- swapIntervalSet = swapInterval;
- swapInterval = -1;
+ swapInterval = gl.getSwapInterval();
+ System.err.println("Swap Interval: "+_swapInterval+" -> "+swapInterval);
+ swapIntervalSet = false;
}
if(null == mPlayer) { return; }
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java
index 22dfa923e..ac5d29854 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java
@@ -51,6 +51,7 @@ import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.font.Font;
+import com.jogamp.junit.util.JunitTracer;
import com.jogamp.newt.Window;
import com.jogamp.newt.event.KeyAdapter;
import com.jogamp.newt.event.KeyEvent;
@@ -65,7 +66,6 @@ import com.jogamp.opengl.GLExtensions;
import com.jogamp.opengl.JoglVersion;
import com.jogamp.opengl.test.junit.graph.TextRendererGLELBase;
import com.jogamp.opengl.test.junit.util.MiscUtils;
-import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.GLArrayDataServer;
import com.jogamp.opengl.util.PMVMatrix;
@@ -105,7 +105,7 @@ public class MovieSimple implements GLEventListener {
private int effects = EFFECT_NORMAL;
private float alpha = 1.0f;
private int swapInterval = 1;
- private int swapIntervalSet = -1;
+ private boolean swapIntervalSet = true;
private GLMediaPlayer mPlayer;
private final boolean mPlayerShared;
@@ -265,10 +265,13 @@ public class MovieSimple implements GLEventListener {
int pts1 = 0;
switch(e.getKeySymbol()) {
case KeyEvent.VK_V: {
- switch(swapIntervalSet) {
- case 0: swapInterval = 1; break;
- default: swapInterval = 0; break;
+ switch(swapInterval) {
+ case 0: swapInterval = -1; break;
+ case -1: swapInterval = 1; break;
+ case 1: swapInterval = 0; break;
+ default: swapInterval = 1; break;
}
+ swapIntervalSet = true;
break;
}
case KeyEvent.VK_O: displayOSD = !displayOSD; break;
@@ -483,7 +486,7 @@ public class MovieSimple implements GLEventListener {
", "+drawable.getClass().getName()+", "+drawable);
if(waitForKey) {
- UITestCase.waitForKey("Init>");
+ JunitTracer.waitForKey("Init>");
}
final Texture tex;
try {
@@ -736,11 +739,13 @@ public class MovieSimple implements GLEventListener {
@Override
public void display(final GLAutoDrawable drawable) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
- if(-1 != swapInterval) {
- gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
+ if( swapIntervalSet ) {
+ final int _swapInterval = swapInterval;
+ gl.setSwapInterval(_swapInterval); // in case switching the drawable (impl. may bound attribute there)
drawable.getAnimator().resetFPSCounter();
- swapIntervalSet = swapInterval;
- swapInterval = -1;
+ swapInterval = gl.getSwapInterval();
+ System.err.println("Swap Interval: "+_swapInterval+" -> "+swapInterval);
+ swapIntervalSet = false;
}
if(null == mPlayer) { return; }
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java
index c2761f694..a144ff1ff 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java
@@ -230,9 +230,7 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
public void reshape(final GLAutoDrawable glad, final int x, final int y, final int width, final int height) {
if( !isInit ) { return; }
final GL2 gl = glad.getGL().getGL2();
- if(-1 != swapInterval) {
- gl.setSwapInterval(swapInterval);
- }
+ gl.setSwapInterval(swapInterval);
reshape(gl, x, y, width, height, width, height);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTDemoListener.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTDemoListener.java
index 68a983a27..3e0b7c780 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/NEWTDemoListener.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTDemoListener.java
@@ -39,6 +39,11 @@ import com.jogamp.newt.event.KeyListener;
import com.jogamp.newt.event.MouseAdapter;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.FPSCounter;
+import com.jogamp.opengl.GL;
+import com.jogamp.opengl.GLAnimatorControl;
+import com.jogamp.opengl.GLAutoDrawable;
+import com.jogamp.opengl.GLRunnable;
import com.jogamp.opengl.util.Gamma;
import com.jogamp.opengl.util.PNGPixelRect;
@@ -290,29 +295,57 @@ public class NEWTDemoListener extends MouseAdapter implements KeyListener {
break;
case KeyEvent.VK_V:
e.setConsumed(true);
- new Thread() {
- public void run() {
- final boolean wasVisible = glWindow.isVisible();
- {
- final Thread t = glWindow.setExclusiveContextThread(null);
- printlnState("[set visible pre]");
- glWindow.setVisible(!wasVisible);
- printlnState("[set visible post]");
- glWindow.setExclusiveContextThread(t);
- }
- if( wasVisible && !e.isControlDown() ) {
- try {
- Thread.sleep(5000);
- } catch (final InterruptedException e) {
- e.printStackTrace();
+ if( e.isControlDown() ) {
+ glWindow.invoke(false, new GLRunnable() {
+ @Override
+ public boolean run(final GLAutoDrawable drawable) {
+ final GL gl = drawable.getGL();
+ final int _i = gl.getSwapInterval();
+ final int i;
+ switch(_i) {
+ case 0: i = -1; break;
+ case -1: i = 1; break;
+ case 1: i = 0; break;
+ default: i = 1; break;
}
- final Thread t = glWindow.setExclusiveContextThread(null);
- printlnState("[reset visible pre]");
- glWindow.setVisible(true);
- printlnState("[reset visible post]");
- glWindow.setExclusiveContextThread(t);
+ gl.setSwapInterval(i);
+
+ final GLAnimatorControl a = drawable.getAnimator();
+ if( null != a ) {
+ a.resetFPSCounter();
+ }
+ if(drawable instanceof FPSCounter) {
+ ((FPSCounter)drawable).resetFPSCounter();
+ }
+ System.err.println("Swap Interval: "+_i+" -> "+i+" -> "+gl.getSwapInterval());
+ return true;
}
- } }.start();
+ });
+ } else {
+ new Thread() {
+ public void run() {
+ final boolean wasVisible = glWindow.isVisible();
+ {
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ printlnState("[set visible pre]");
+ glWindow.setVisible(!wasVisible);
+ printlnState("[set visible post]");
+ glWindow.setExclusiveContextThread(t);
+ }
+ if( wasVisible && !e.isControlDown() ) {
+ try {
+ Thread.sleep(5000);
+ } catch (final InterruptedException e) {
+ e.printStackTrace();
+ }
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ printlnState("[reset visible pre]");
+ glWindow.setVisible(true);
+ printlnState("[reset visible post]");
+ glWindow.setExclusiveContextThread(t);
+ }
+ } }.start();
+ }
break;
case KeyEvent.VK_W:
e.setConsumed(true);