diff options
author | Sven Gothel <[email protected]> | 2010-06-16 06:57:15 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-06-16 06:57:15 +0200 |
commit | 0d24458c68ac1bb92da21a1701633f8f32a267bb (patch) | |
tree | 41ce1187fec49d74079c5056df0cbb296c468d28 /src/jogl/classes/com/jogamp/opengl/impl/GLDrawableHelper.java | |
parent | c0ece5ebd634662f99f3217bb749e2c4795f9de6 (diff) |
JOGL.GLAutoDrawable:
- Add: 'public void addGLEventListener(int index, GLEventListener listener)'
Fixes previous GLWindow addition, ie public in interface and common impl. behavior.
- Add: 'public void invoke(boolean wait, GLRunnable glRunnable)'
- Change: 'public void display()' semantics, in regards to the GLRunnable queue
New: GLRunnable, invoke() at GLAutoDrawable
Allows injection of GL commands from other threads, executed after the
GLEventListener's display() notifyier by the GLAutoDrawable.
NEWT:
- Fix EDTUTil.invokeAndWait() and Display.enqueueAndWait() impl.,
where we only wait for the single action/event to be processed now.
JUnit: NEWT Parenting
- Added test cases for Swing (JFrame, JPanel and COntainer) with NewtCanvasAWT
- Added thread calling 'invoke(true, GLRunnable)'
- start Animator ASAP
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/impl/GLDrawableHelper.java')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/impl/GLDrawableHelper.java | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableHelper.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableHelper.java index fcd662048..8fefe149e 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableHelper.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableHelper.java @@ -51,6 +51,7 @@ public class GLDrawableHelper { private static final boolean VERBOSE = Debug.verbose(); private static final boolean NVIDIA_CRASH_WORKAROUND = Debug.isPropertyDefined("jogl.nvidia.crash.workaround", true); private boolean autoSwapBufferMode = true; + private ArrayList glRunnables = new ArrayList(); // one shot GL tasks public GLDrawableHelper() { } @@ -100,6 +101,7 @@ public class GLDrawableHelper { for (Iterator iter = listeners.iterator(); iter.hasNext(); ) { ((GLEventListener) iter.next()).display(drawable); } + execGLRunnables(drawable); } public void reshape(GLAutoDrawable drawable, @@ -109,6 +111,55 @@ public class GLDrawableHelper { } } + private void execGLRunnables(GLAutoDrawable drawable) { + if(glRunnables.size()>0) { + ArrayList _glRunnables = null; + synchronized(glRunnables) { + if(glRunnables.size()>0) { + _glRunnables = glRunnables; + glRunnables = new ArrayList(); + } + } + if(null!=_glRunnables) { + for (Iterator iter = _glRunnables.iterator(); iter.hasNext(); ) { + ((GLRunnable) iter.next()).run(drawable); + } + } + } + } + + private void invokeLater(GLRunnable glRunnable) { + synchronized(glRunnables) { + glRunnables.add(glRunnable); + glRunnables.notifyAll(); + } + } + + public void invoke(boolean wait, GLRunnable glRunnable) { + if(glRunnable == null) { + return; + } + Object lock = new Object(); + GLRunnableTask rTask = new GLRunnableTask(glRunnable, wait?lock:null/*, true*/); + Throwable throwable = null; + synchronized(lock) { + invokeLater(rTask); + if( wait ) { + try { + lock.wait(); + } catch (InterruptedException ie) { + throwable = ie; + } + } + } + if(null==throwable) { + throwable = rTask.getThrowable(); + } + if(null!=throwable) { + throw new RuntimeException(throwable); + } + } + public void setAutoSwapBufferMode(boolean onOrOff) { autoSwapBufferMode = onOrOff; } |