From b76c821858e7ee132aa08cc8d9d61e82eb9aa53f Mon Sep 17 00:00:00 2001 From: Gerard Ziemski Date: Sun, 12 Oct 2003 07:00:38 +0000 Subject: Disabling the context updater for now - not thread safe yet. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@68 232f8b59-042b-4e1e-8c03-345bb8c30851 --- make/cgl-macosx.cfg | 1 + make/stub_includes/macosx/window-system.c | 1 + src/native/jogl/MacOSXWindowSystemInterface.m | 8 ++++++++ .../games/jogl/impl/macosx/MacOSXGLContext.java | 2 +- .../jogl/impl/macosx/MacOSXOnscreenGLContext.java | 21 ++++++++++++++++++++- 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/make/cgl-macosx.cfg b/make/cgl-macosx.cfg index 649fc7e30..5f32db492 100644 --- a/make/cgl-macosx.cfg +++ b/make/cgl-macosx.cfg @@ -18,6 +18,7 @@ CustomCCode extern Bool makeCurrentContext(void* nsContext, void* nsView); CustomCCode extern Bool clearCurrentContext(void* nsContext, void* nsView); CustomCCode extern Bool deleteContext(void* nsContext, void* nsView); CustomCCode extern Bool flushBuffer(void* nsContext, void* nsView); +CustomCCode extern void updateContext(void* nsContext, void* nsView); CustomCCode extern void* updateContextRegister(void* nsContext, void* nsView); CustomCCode extern void updateContextUnregister(void* nsContext, void* nsView, void* updater); diff --git a/make/stub_includes/macosx/window-system.c b/make/stub_includes/macosx/window-system.c index 15506299b..da317e393 100644 --- a/make/stub_includes/macosx/window-system.c +++ b/make/stub_includes/macosx/window-system.c @@ -8,6 +8,7 @@ Bool makeCurrentContext(void* nsContext, void* nsView); Bool clearCurrentContext(void* nsContext, void* nsView); Bool deleteContext(void* nsContext, void* nsView); Bool flushBuffer(void* nsContext, void* nsView); +void updateContext(void* nsContext, void* nsView); void* updateContextRegister(void* nsContext, void* nsView); void updateContextUnregister(void* nsContext, void* nsView, void* updater); diff --git a/src/native/jogl/MacOSXWindowSystemInterface.m b/src/native/jogl/MacOSXWindowSystemInterface.m index ceb07a63d..3d852571c 100644 --- a/src/native/jogl/MacOSXWindowSystemInterface.m +++ b/src/native/jogl/MacOSXWindowSystemInterface.m @@ -96,6 +96,14 @@ Bool flushBuffer(void* context, void* view) return true; } +void updateContext(void* context, void* view) +{ +//fprintf(stderr, "updateContext context=%p, view=%p\n", context, view); + NSOpenGLContext *nsContext = (NSOpenGLContext*)context; + + [nsContext update]; +} + void* updateContextRegister(void* context, void* view) { //fprintf(stderr, "updateContextRegister context=%p, view=%p\n", context, view); diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java index e6169a4b9..e1618a15a 100644 --- a/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java +++ b/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java @@ -108,7 +108,7 @@ public abstract class MacOSXGLContext extends GLContext if (nsContext == 0) { throw new GLException("Error creating nsContext"); } - updater = CGL.updateContextRegister(nsContext, nsView); + //updater = CGL.updateContextRegister(nsContext, nsView); // gznote: not thread safe yet! GLContextShareSet.contextCreated(this); } diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java index ec46de0d8..97020de28 100644 --- a/src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java +++ b/src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java @@ -50,6 +50,7 @@ public class MacOSXOnscreenGLContext extends MacOSXGLContext { private JAWT_DrawingSurface ds; private JAWT_DrawingSurfaceInfo dsi; private JAWT_MacOSXDrawingSurfaceInfo macosxdsi; + private Runnable myDeferredReshapeAction; // Variables for pbuffer support List pbuffersToInstantiate = new ArrayList(); @@ -61,6 +62,24 @@ public class MacOSXOnscreenGLContext extends MacOSXGLContext { super(component, capabilities, chooser, shareWith); } + // gznote: remove when updater is thread safe! + public synchronized void invokeGL(final Runnable runnable, boolean isReshape, Runnable initAction) throws GLException { + if (isReshape) { + myDeferredReshapeAction = new Runnable() { + public void run() { + CGL.updateContext(nsContext, nsView); + runnable.run(); + } + }; + } else { + if (myDeferredReshapeAction != null) { + super.invokeGL(myDeferredReshapeAction, true, initAction); + myDeferredReshapeAction = null; + } + super.invokeGL(runnable, isReshape, initAction); + } + } + protected GL createGL() { return new MacOSXGLImpl(this); } @@ -167,7 +186,7 @@ public class MacOSXOnscreenGLContext extends MacOSXGLContext { // OpenGL nsContext so it will be recreated if ((res & JAWTFactory.JAWT_LOCK_SURFACE_CHANGED) != 0) { if (nsContext != 0) { - CGL.updateContextUnregister(nsContext, nsView, updater); + //CGL.updateContextUnregister(nsContext, nsView, updater); // gznote: not thread safe yet! if (!CGL.deleteContext(nsContext, nsView)) { throw new GLException("Unable to delete old GL nsContext after surface changed"); } -- cgit v1.2.3