diff options
author | Gerard Ziemski <[email protected]> | 2003-10-12 06:31:59 +0000 |
---|---|---|
committer | Gerard Ziemski <[email protected]> | 2003-10-12 06:31:59 +0000 |
commit | fbdf8c337805b02385bf43b65aad93c20a2e3ad2 (patch) | |
tree | ae1575e8291ee93c85a1c00e6cbb5e00a0c59255 /src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java | |
parent | 30664570919282ddef3d0496251a3bfb8558b298 (diff) |
Implemented PBuffers (available in >= Panther). Reimplemented window resizing using update listener
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@67 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java')
-rw-r--r-- | src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java index 53e5986ec..e6169a4b9 100644 --- a/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java +++ b/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java @@ -49,6 +49,8 @@ public abstract class MacOSXGLContext extends GLContext { private static JAWT jawt; protected long nsContext; // NSOpenGLContext + protected long nsView; // NSView + protected long updater; // ContextUpdater // Table that holds the addresses of the native C-language entry points for // OpenGL functions. private GLProcAddressTable glProcAddressTable; @@ -61,6 +63,11 @@ public abstract class MacOSXGLContext extends GLContext super(component, capabilities, chooser, shareWith); } + protected GL createGL() + { + return new MacOSXGLImpl(this); + } + protected String mapToRealGLFunctionName(String glFunctionName) { return glFunctionName; @@ -88,11 +95,51 @@ public abstract class MacOSXGLContext extends GLContext * Creates and initializes an appropriate OpenGl nsContext. Should only be * called by {@link makeCurrent(Runnable)}. */ - protected abstract void create(); + protected void create() { + MacOSXGLContext other = (MacOSXGLContext) GLContextShareSet.getShareContext(this); + long share = 0; + if (other != null) { + share = other.getNSContext(); + if (share == 0) { + throw new GLException("GLContextShareSet returned an invalid OpenGL context"); + } + } + nsContext = CGL.createContext(share, nsView); + if (nsContext == 0) { + throw new GLException("Error creating nsContext"); + } + updater = CGL.updateContextRegister(nsContext, nsView); + GLContextShareSet.contextCreated(this); + } - protected abstract boolean makeCurrent(Runnable initAction) throws GLException; + protected synchronized boolean makeCurrent(Runnable initAction) throws GLException { + boolean created = false; + if (nsContext == 0) { + create(); + if (DEBUG) { + System.err.println("!!! Created GL nsContext for " + getClass().getName()); + } + created = true; + } + + if (!CGL.makeCurrentContext(nsContext, nsView)) { + throw new GLException("Error making nsContext current"); + } + + if (created) { + resetGLFunctionAvailability(); + if (initAction != null) { + initAction.run(); + } + } + return true; + } - protected abstract void free() throws GLException; + protected synchronized void free() throws GLException { + if (!CGL.clearCurrentContext(nsContext, nsView)) { + throw new GLException("Error freeing OpenGL nsContext"); + } + } protected abstract void swapBuffers() throws GLException; @@ -136,6 +183,10 @@ public abstract class MacOSXGLContext extends GLContext return nsContext; } + protected long getNSView() { + return nsView; + } + protected JAWT getJAWT() { if (jawt == null) |