aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRami Santina <[email protected]>2011-08-09 20:51:12 +0300
committerRami Santina <[email protected]>2011-08-09 20:51:12 +0300
commit91d3bf4ea69046684540402cb1fd46e70682a6c5 (patch)
tree5da0ca5116e82617fa7a7a7ff5c3c2a7bf30617a /src
parentf98a8e29b46b6cfbd2c3e695a02093b19468e95d (diff)
GLRunnable API Change: Return boolean indicating whether the back buffer shall be updated before swap.
This allows color selection GLRunnables, executed after the GLEventListener.
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLRunnable.java6
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableHelper.java30
-rw-r--r--src/jogl/classes/jogamp/opengl/GLRunnableTask.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/GLRunnableDummy.java9
7 files changed, 45 insertions, 30 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLRunnable.java b/src/jogl/classes/javax/media/opengl/GLRunnable.java
index de0f5df48..cbd086c77 100644
--- a/src/jogl/classes/javax/media/opengl/GLRunnable.java
+++ b/src/jogl/classes/javax/media/opengl/GLRunnable.java
@@ -41,7 +41,11 @@ public interface GLRunnable {
/**
* Called by the drawable to initiate one-shot OpenGL commands by the
* client, like {@link GLEventListener#display(GLAutoDrawable)}.
+ *
+ * @param drawable the associated drawable the implementation shall use
+ * @return false if impl invalidates the back buffers, hence {@link GLAutoDrawable#display()} will
+ * issue another {@link GLEventListener#display(GLAutoDrawable)} call. Otherwise true.
*/
- void run(GLAutoDrawable drawable);
+ boolean run(GLAutoDrawable drawable);
}
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
index 887e571cc..9353479ab 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
@@ -156,16 +156,21 @@ public class GLDrawableHelper {
}
public final void display(GLAutoDrawable drawable) {
- synchronized(listenersLock) {
- for (int i=0; i < listeners.size(); i++) {
- final GLEventListener listener = listeners.get(i) ;
- // GLEventListener may need to be init,
- // in case this one is added after the realization of the GLAutoDrawable
- init( listener, drawable, true ) ;
- listener.display(drawable);
- }
+ displayImpl(drawable);
+ if(!execGLRunnables(drawable)) {
+ displayImpl(drawable);
}
- execGLRunnables(drawable);
+ }
+ private void displayImpl(GLAutoDrawable drawable) {
+ synchronized(listenersLock) {
+ for (int i=0; i < listeners.size(); i++) {
+ final GLEventListener listener = listeners.get(i) ;
+ // GLEventListener may need to be init,
+ // in case this one is added after the realization of the GLAutoDrawable
+ init( listener, drawable, true ) ;
+ listener.display(drawable);
+ }
+ }
}
private void reshape(GLEventListener listener, GLAutoDrawable drawable,
@@ -184,7 +189,8 @@ public class GLDrawableHelper {
}
}
- private void execGLRunnables(GLAutoDrawable drawable) {
+ private boolean execGLRunnables(GLAutoDrawable drawable) {
+ boolean res = true;
if(glRunnables.size()>0) {
// swap one-shot list asap
ArrayList<GLRunnable> _glRunnables = null;
@@ -194,12 +200,14 @@ public class GLDrawableHelper {
glRunnables = new ArrayList<GLRunnable>();
}
}
+
if(null!=_glRunnables) {
for (int i=0; i < _glRunnables.size(); i++) {
- _glRunnables.get(i).run(drawable);
+ res = _glRunnables.get(i).run(drawable) && res;
}
}
}
+ return res;
}
public final void setAnimator(GLAnimatorControl animator) throws GLException {
diff --git a/src/jogl/classes/jogamp/opengl/GLRunnableTask.java b/src/jogl/classes/jogamp/opengl/GLRunnableTask.java
index e5b66b985..448f68423 100644
--- a/src/jogl/classes/jogamp/opengl/GLRunnableTask.java
+++ b/src/jogl/classes/jogamp/opengl/GLRunnableTask.java
@@ -50,10 +50,11 @@ public class GLRunnableTask implements GLRunnable {
isExecuted = false;
}
- public void run(GLAutoDrawable drawable) {
+ public boolean run(GLAutoDrawable drawable) {
+ boolean res = true;
if(null == notifyObject) {
try {
- runnable.run(drawable);
+ res = runnable.run(drawable);
} catch (Throwable t) {
runnableException = t;
if(catchExceptions) {
@@ -67,7 +68,7 @@ public class GLRunnableTask implements GLRunnable {
} else {
synchronized (notifyObject) {
try {
- runnable.run(drawable);
+ res = runnable.run(drawable);
} catch (Throwable t) {
runnableException = t;
if(catchExceptions) {
@@ -81,6 +82,7 @@ public class GLRunnableTask implements GLRunnable {
}
}
}
+ return res;
}
public boolean isExecuted() { return isExecuted; }
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 a837c56f8..7a10c4950 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
@@ -254,7 +254,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
else if(arg0.getKeyCode() == KeyEvent.VK_V) {
if(null != autoDrawable) {
autoDrawable.invoke(false, new GLRunnable() {
- public void run(GLAutoDrawable drawable) {
+ public boolean run(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
int i = gl.getSwapInterval();
i = i==0 ? 1 : 0;
@@ -267,6 +267,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
((FPSCounter)drawable).resetFPSCounter();
}
System.err.println("Swap Interval: "+i);
+ return true;
}
});
}
@@ -275,7 +276,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
rotate(-1);
if(null != autoDrawable) {
autoDrawable.invoke(false, new GLRunnable() {
- public void run(GLAutoDrawable drawable) {
+ public boolean run(GLAutoDrawable drawable) {
try {
final String type = Region.isVBAA(renderModes) ? "vbaa0-msaa1" : "vbaa1-msaa0" + ( Region.isNonUniformWeight(renderModes) ? "-vc" : "-uc" ) ;
printScreen(drawable, "./", "demo-"+type, "snap"+screenshot_num, false);
@@ -284,7 +285,8 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
- }
+ }
+ 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 b89f87be4..0fe48e550 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
@@ -281,7 +281,7 @@ public abstract class UIListenerBase01 implements GLEventListener {
else if(arg0.getKeyCode() == KeyEvent.VK_V) {
if(null != autoDrawable) {
autoDrawable.invoke(false, new GLRunnable() {
- public void run(GLAutoDrawable drawable) {
+ public boolean run(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
int i = gl.getSwapInterval();
i = i==0 ? 1 : 0;
@@ -291,6 +291,7 @@ public abstract class UIListenerBase01 implements GLEventListener {
a.resetFPSCounter();
}
System.err.println("Swap Interval: "+i);
+ return true;
}
});
}
@@ -299,7 +300,7 @@ public abstract class UIListenerBase01 implements GLEventListener {
rotate(-1);
if(null != autoDrawable) {
autoDrawable.invoke(false, new GLRunnable() {
- public void run(GLAutoDrawable drawable) {
+ public boolean run(GLAutoDrawable drawable) {
try {
final String type = ( 1 == rRenderer.getRenderModes() ) ? "r2t0-msaa1" : "r2t1-msaa0" ;
printScreen(drawable, "./", "demo-"+type, "snap"+screenshot_num, false);
@@ -308,7 +309,8 @@ public abstract class UIListenerBase01 implements GLEventListener {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
- }
+ }
+ return true;
}
});
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java
index 9a6548dd4..afddb5676 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java
@@ -92,11 +92,12 @@ public class TestGLDebug01NEWT extends UITestCase {
Assert.assertEquals((null == glDebugExt) ? false : enable, ctx.isGLDebugMessageEnabled());
if(ctx.isGLDebugMessageEnabled() && null != dbgTstMsg && 0 <= dbgTstId) {
window.invoke(true, new GLRunnable() {
- public void run(GLAutoDrawable drawable) {
+ public boolean run(GLAutoDrawable drawable) {
drawable.getContext().glDebugMessageInsert(GL2GL3.GL_DEBUG_SOURCE_APPLICATION_ARB,
GL2GL3.GL_DEBUG_TYPE_OTHER_ARB,
dbgTstId,
GL2GL3.GL_DEBUG_SEVERITY_MEDIUM_ARB, dbgTstMsg);
+ return true;
}
});
Assert.assertEquals(true, myGLDebugListener.received());
@@ -128,8 +129,9 @@ public class TestGLDebug01NEWT extends UITestCase {
window.getContext().addGLDebugListener(myGLDebugListener);
window.invoke(true, new GLRunnable() {
- public void run(GLAutoDrawable drawable) {
+ public boolean run(GLAutoDrawable drawable) {
drawable.getGL().glBindFramebuffer(-1, -1); // ERROR !
+ return true;
}
} );
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/GLRunnableDummy.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/GLRunnableDummy.java
index 620219dc7..1ca74774b 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/GLRunnableDummy.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/GLRunnableDummy.java
@@ -28,12 +28,6 @@
package com.jogamp.opengl.test.junit.newt.parenting;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.AfterClass;
-import org.junit.Test;
-
import javax.media.opengl.*;
public class GLRunnableDummy implements GLRunnable {
@@ -42,7 +36,7 @@ public class GLRunnableDummy implements GLRunnable {
float b=0.0f;
float d=0.1f;
- public void run(GLAutoDrawable drawable) {
+ public boolean run(GLAutoDrawable drawable) {
GL2ES1 gl = drawable.getGL().getGL2ES1();
gl.glClearColor(r, g, b, 1f);
r+=d;
@@ -53,5 +47,6 @@ public class GLRunnableDummy implements GLRunnable {
r=0f;
d*=-1f;
}
+ return true;
}
}