aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java14
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) {