*** MacOSXCGLContext.java.repo 2012-03-15 15:23:08.000000000 -0400 --- MacOSXCGLContext.java 2012-03-15 15:28:42.000000000 -0400 *************** *** 396,401 **** --- 396,402 ---- class NSOpenGLImpl implements GLBackendImpl { long nsOpenGLLayer = 0; long nsOpenGLLayerPFmt = 0; + int vsyncTimeout = 16; public boolean isNSContext() { return true; } *************** *** 555,567 **** CGL.setNSOpenGLLayerSwapInterval(nsOpenGLLayer, interval); } CGL.setSwapInterval(contextHandle, interval); return true; } public boolean swapBuffers() { if(0 != nsOpenGLLayer) { // sync w/ CALayer renderer - wait until next frame is required (v-sync) ! CGL.waitUntilNSOpenGLLayerIsReady(nsOpenGLLayer, 16); // timeout 16ms -> 60Hz } if(CGL.flushBuffer(contextHandle)) { if(0 != nsOpenGLLayer) { --- 556,577 ---- CGL.setNSOpenGLLayerSwapInterval(nsOpenGLLayer, interval); } CGL.setSwapInterval(contextHandle, interval); + if (interval == 0) { + // v-sync is disabled, so setting the timeout to a minimum + // of ms (which corresponds to 500fps). + vsyncTimeout = 2; + } 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) { // sync w/ CALayer renderer - wait until next frame is required (v-sync) ! CGL.waitUntilNSOpenGLLayerIsReady(nsOpenGLLayer, vsyncTimeout); } if(CGL.flushBuffer(contextHandle)) { if(0 != nsOpenGLLayer) {