diff options
author | Kenneth Russel <[email protected]> | 2008-06-27 00:04:31 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2008-06-27 00:04:31 +0000 |
commit | d347e888b8bbc189e8844a2ae3c819c39f520c9b (patch) | |
tree | 9ee71ac50a4790e2a761ca41e305a059fa2f66c2 /src/demos | |
parent | 8bc1a27e399cf6d22806e680ca1c16b4f72b8930 (diff) |
Periodically release the OpenGL context to allow the AWT to dispatch
native messages on some platforms
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/branches/JOGL_2_SANDBOX@252 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
Diffstat (limited to 'src/demos')
-rwxr-xr-x | src/demos/es1/RedSquare.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/demos/es1/RedSquare.java b/src/demos/es1/RedSquare.java index 97b6730..fe69983 100755 --- a/src/demos/es1/RedSquare.java +++ b/src/demos/es1/RedSquare.java @@ -112,6 +112,7 @@ public class RedSquare implements MouseListener { long startTime = System.currentTimeMillis(); long curTime; + int frameCount = 0; while (!ml.quit && ((curTime = System.currentTimeMillis()) - startTime) < 20000) { gl.glClear(GL2ES1.GL_COLOR_BUFFER_BIT | GL2ES1.GL_DEPTH_BUFFER_BIT); @@ -140,6 +141,20 @@ public class RedSquare implements MouseListener { } window.pumpMessages(); + + // Periodically release the OpenGL context to allow + // messages to be pumped in some configurations (in + // particular, if using the AWT) + if (++frameCount > 10) { + frameCount = 0; + context.release(); + if ((res = context.makeCurrent()) == GLContext.CONTEXT_NOT_CURRENT) { + System.out.println("Unexpected error making context current again"); + System.exit(0); + } else if (res == GLContext.CONTEXT_CURRENT_NEW) { + gl = context.getGL().getGL2ES1(); + } + } } // Shut things down cooperatively |