summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/jogamp')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java16
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java48
2 files changed, 50 insertions, 14 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index 99693aabe..283b0c751 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -196,8 +196,18 @@ public abstract class GLContextImpl extends GLContext {
return gl;
}
- // This is only needed for Mac OS X on-screen contexts
- protected void update() throws GLException { }
+ /**
+ * Call this method to notify the OpenGL context
+ * that the drawable has changed (size or position).
+ *
+ * <p>
+ * This is currently being used and overridden by Mac OSX,
+ * which issues the {@link jogamp.opengl.macosx.cgl.CGL#updateContext(long) NSOpenGLContext update()} call.
+ * </p>
+ *
+ * @throws GLException
+ */
+ protected void drawableUpdatedNotify() throws GLException { }
boolean lockFailFast = true;
Object lockFailFastSync = new Object();
@@ -362,7 +372,7 @@ public abstract class GLContextImpl extends GLContext {
if (current == this) {
// Assume we don't need to make this context current again
// For Mac OS X, however, we need to update the context to track resizes
- update();
+ drawableUpdatedNotify();
return CONTEXT_CURRENT;
} else {
current.release();
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;
}