diff options
author | Julien Gouesse <[email protected]> | 2014-02-15 12:21:05 +0100 |
---|---|---|
committer | Julien Gouesse <[email protected]> | 2014-02-15 12:21:05 +0100 |
commit | fc3a8f6690809bdcf4ef4f4f89ca776ac7ae2217 (patch) | |
tree | a6fa47d824b2ea22b9aea5091e2461b3902f52df | |
parent | 537fadc98cbcdf2409b82b70cc8ad043864a77a6 (diff) |
Calls Thread.sleep(5) only when there is no current OpenGL context yet in JoglCanvasRenderer
-rw-r--r-- | ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java index a86e3bc..2e8cd44 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java @@ -82,25 +82,29 @@ public class JoglCanvasRenderer implements CanvasRenderer { @Override public void makeCurrentContext() throws Ardor3dException { int value = GLContext.CONTEXT_NOT_CURRENT; - int attempt = 0; - do { + for (int attempt = 0;;) { try { value = _context.makeCurrent(); } catch (final GLException gle) { gle.printStackTrace(); } finally { attempt++; + } + if (value == GLContext.CONTEXT_NOT_CURRENT) { if (attempt == MAX_CONTEXT_GRAB_ATTEMPTS) { // failed, throw exception throw new Ardor3dException("Failed to claim OpenGL context."); + } else { + try { + Thread.sleep(5); + } catch (final InterruptedException e1) { + e1.printStackTrace(); + } } + } else { + break; } - try { - Thread.sleep(5); - } catch (final InterruptedException e1) { - e1.printStackTrace(); - } - } while (value == GLContext.CONTEXT_NOT_CURRENT); + } if (ContextManager.getCurrentContext() != null) { if (value == GLContext.CONTEXT_CURRENT_NEW) { ContextManager.getCurrentContext().contextLost(); |