summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
authorAndres Colubri <[email protected]>2012-04-22 00:50:46 +0200
committerSven Gothel <[email protected]>2012-04-22 00:50:46 +0200
commit218d67fc0222d7709b21c45792d44501351939c4 (patch)
tree6ffb421b81f0ac2565add94b1add0f6957e22094 /src/jogl/classes
parentcb39ab630d59fe33faa3a0dd7093c385a6a4a66d (diff)
Recognize swap-interval in NSOpenGLLayer mode
Diffstat (limited to 'src/jogl/classes')
-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) {