aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/macosx/cgl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-10-13 03:33:28 +0200
committerSven Gothel <[email protected]>2011-10-13 03:33:28 +0200
commit946c98fd196802755e9e13a9c5db75650a564466 (patch)
treec3aa9b62a1cea7e3a2dc8c306decbbbe273f3b4c /src/jogl/classes/jogamp/opengl/macosx/cgl
parent22f8e786219166019688ff2eea6ff9570c117544 (diff)
JOGL/OSX: Properly utilize NSOpenGLContext update() via ContextUpdater, which only holds the 'update' state now.
Avoid calling updater() for every makeCurrent(), but if view's frame has changed only. This solves the pixel flickering experienced on OSX. - GLContextImpl:update() -> drawableUpdatedNotify() w/ comments - ContextUpdater holds context, view, old view frame and the update state. It doesn't issue NSOpenGLContext update() by itself, but allows querying and clearing the update flag. - MacOSXOnscreenCGLContext impl drawableUpdatedNotify() - register via ContextUpdater, and use it if available.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/macosx/cgl')
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java48
1 files changed, 37 insertions, 11 deletions
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java
index 55d3a0853..393bd398b 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java
@@ -49,41 +49,67 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext {
super(drawable, shareWith);
}
- @Override
+ @Override
protected void makeCurrentImpl(boolean newCreated) throws GLException {
super.makeCurrentImpl(newCreated);
- CGL.updateContext(contextHandle);
+ drawableUpdatedNotify();
}
- @Override
+ @Override
protected void releaseImpl() throws GLException {
super.releaseImpl();
}
- @Override
+ @Override
protected void swapBuffers() {
if (!CGL.flushBuffer(contextHandle)) {
throw new GLException("Error swapping buffers");
}
}
- @Override
- protected void update() throws GLException {
- if (contextHandle == 0) {
- throw new GLException("Context not created");
+ @Override
+ protected void drawableUpdatedNotify() throws GLException {
+ if(0==updateHandle || CGL.updateContextNeedsUpdate(updateHandle)) {
+ if (contextHandle == 0) {
+ throw new GLException("Context not created");
+ }
+ CGL.updateContext(contextHandle);
}
- CGL.updateContext(contextHandle);
}
-
+
+ protected long updateHandle = 0;
+
+ @Override
protected boolean createImpl() {
- return create(false, false);
+ boolean res = create(false, false);
+ if(res && isNSContext) {
+ if(0 != updateHandle) {
+ throw new InternalError("XXX1");
+ }
+ updateHandle = CGL.updateContextRegister(contextHandle, drawable.getHandle());
+ if(0 == updateHandle) {
+ throw new InternalError("XXX2");
+ }
+ }
+ return res;
}
+ @Override
+ protected void destroyImpl() throws GLException {
+ if ( 0 != updateHandle ) {
+ CGL.updateContextUnregister(updateHandle);
+ updateHandle = 0;
+ }
+ super.destroyImpl();
+ }
+
+ @Override
public void setOpenGLMode(int mode) {
if (mode != MacOSXCGLDrawable.NSOPENGL_MODE)
throw new GLException("OpenGL mode switching not supported for on-screen GLContexts");
}
+ @Override
public int getOpenGLMode() {
return MacOSXCGLDrawable.NSOPENGL_MODE;
}