diff options
author | Andres Colubri <[email protected]> | 2012-04-22 00:50:46 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-04-22 00:50:46 +0200 |
commit | 218d67fc0222d7709b21c45792d44501351939c4 (patch) | |
tree | 6ffb421b81f0ac2565add94b1add0f6957e22094 /src | |
parent | cb39ab630d59fe33faa3a0dd7093c385a6a4a66d (diff) |
Recognize swap-interval in NSOpenGLLayer mode
Diffstat (limited to 'src')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 19a1469cb..7d7dae950 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -396,6 +396,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl class NSOpenGLImpl implements GLBackendImpl { long nsOpenGLLayer = 0; long nsOpenGLLayerPFmt = 0; + int vsyncTimeout = 16; public boolean isNSContext() { return true; } @@ -555,13 +556,22 @@ public abstract class MacOSXCGLContext extends GLContextImpl CGL.setNSOpenGLLayerSwapInterval(nsOpenGLLayer, interval); } CGL.setSwapInterval(contextHandle, interval); + if (interval == 0) { + // v-sync is disabled, frames were drawn as quickly as possible without adding any + // timeout delay. + vsyncTimeout = 0; + } else { + // v-sync is enabled. Swaping interval of 1 means a + // timeout of 16ms -> 60Hz, 60fps + vsyncTimeout = interval * 16; + } return true; } public boolean swapBuffers() { - if(0 != nsOpenGLLayer) { + if(0 != nsOpenGLLayer && 0 < vsyncTimeout) { // sync w/ CALayer renderer - wait until next frame is required (v-sync) - CGL.waitUntilNSOpenGLLayerIsReady(nsOpenGLLayer, 16); // timeout 16ms -> 60Hz + CGL.waitUntilNSOpenGLLayerIsReady(nsOpenGLLayer, vsyncTimeout); } if(CGL.flushBuffer(contextHandle)) { if(0 != nsOpenGLLayer) { |