diff options
author | Kenneth Russel <[email protected]> | 2003-07-08 09:20:04 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2003-07-08 09:20:04 +0000 |
commit | 4f936be964c9e8613a5e43e1d88490ff7f550ec9 (patch) | |
tree | 74a2c01c6093d89ac123d08642b11a2007cc99e2 /src/net/java/games/jogl/impl/macosx | |
parent | 93d272a0525ec57aa3cd584f15cde6cf2a637e0c (diff) |
Added sharing of display lists and textures among OpenGL contexts
through new methods in GLDrawableFactory; GLContext has not been
exposed in the public API. Tested with new simple TestContextSharing
demonstration on Windows, Linux and Mac OS X.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@18 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java/games/jogl/impl/macosx')
5 files changed, 39 insertions, 13 deletions
diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXDummyGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXDummyGLContext.java index 05ed7d9dc..02ca808c9 100644 --- a/src/net/java/games/jogl/impl/macosx/MacOSXDummyGLContext.java +++ b/src/net/java/games/jogl/impl/macosx/MacOSXDummyGLContext.java @@ -54,7 +54,7 @@ class MacOSXDummyGLContext extends MacOSXGLContext private MacOSXGLImpl gl; MacOSXDummyGLContext(MacOSXGLImpl gl) { - super(null, null, null); + super(null, null, null, null); this.gl = gl; } diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java index d35392ac1..53e5986ec 100644 --- a/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java +++ b/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java @@ -53,9 +53,12 @@ public abstract class MacOSXGLContext extends GLContext // OpenGL functions. private GLProcAddressTable glProcAddressTable; - public MacOSXGLContext(Component component, GLCapabilities capabilities, GLCapabilitiesChooser chooser) + public MacOSXGLContext(Component component, + GLCapabilities capabilities, + GLCapabilitiesChooser chooser, + GLContext shareWith) { - super(component, capabilities, chooser); + super(component, capabilities, chooser, shareWith); } protected String mapToRealGLFunctionName(String glFunctionName) @@ -96,6 +99,10 @@ public abstract class MacOSXGLContext extends GLContext protected long dynamicLookupFunction(String glFuncName) { return CGL.getProcAddress(glFuncName); } + + public boolean isCreated() { + return (nsContext != 0); + } protected void resetGLFunctionAvailability() { @@ -125,6 +132,10 @@ public abstract class MacOSXGLContext extends GLContext // Internals only below this point // + protected long getNSContext() { + return nsContext; + } + protected JAWT getJAWT() { if (jawt == null) diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXGLContextFactory.java b/src/net/java/games/jogl/impl/macosx/MacOSXGLContextFactory.java index 323f75480..f3e002c22 100644 --- a/src/net/java/games/jogl/impl/macosx/MacOSXGLContextFactory.java +++ b/src/net/java/games/jogl/impl/macosx/MacOSXGLContextFactory.java @@ -44,11 +44,14 @@ import net.java.games.jogl.*; import net.java.games.jogl.impl.*; public class MacOSXGLContextFactory extends GLContextFactory { - public GLContext createGLContext(Component component, GLCapabilities capabilities, GLCapabilitiesChooser chooser) { + public GLContext createGLContext(Component component, + GLCapabilities capabilities, + GLCapabilitiesChooser chooser, + GLContext shareWith) { if (component != null) { - return new MacOSXOnscreenGLContext(component, capabilities, chooser); + return new MacOSXOnscreenGLContext(component, capabilities, chooser, shareWith); } else { - return new MacOSXOffscreenGLContext(capabilities, chooser); + return new MacOSXOffscreenGLContext(capabilities, chooser, shareWith); } } } diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXOffscreenGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXOffscreenGLContext.java index 46d754462..e9f3bed24 100644 --- a/src/net/java/games/jogl/impl/macosx/MacOSXOffscreenGLContext.java +++ b/src/net/java/games/jogl/impl/macosx/MacOSXOffscreenGLContext.java @@ -49,8 +49,10 @@ public class MacOSXOffscreenGLContext extends MacOSXGLContext private int width; private int height; - public MacOSXOffscreenGLContext(GLCapabilities capabilities, GLCapabilitiesChooser chooser) { - super(null, capabilities, chooser); + public MacOSXOffscreenGLContext(GLCapabilities capabilities, + GLCapabilitiesChooser chooser, + GLContext shareWith) { + super(null, capabilities, chooser, shareWith); System.err.println("MacOSXOffscreenGLContext not implemented yet"); } diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java index 5b0df9052..8f75fd561 100644 --- a/src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java +++ b/src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java @@ -53,8 +53,11 @@ public class MacOSXOnscreenGLContext extends MacOSXGLContext { private long nsView; // NSView private Runnable myDeferredReshapeAction; - public MacOSXOnscreenGLContext(Component component, GLCapabilities capabilities, GLCapabilitiesChooser chooser) { - super(component, capabilities, chooser); + public MacOSXOnscreenGLContext(Component component, + GLCapabilities capabilities, + GLCapabilitiesChooser chooser, + GLContext shareWith) { + super(component, capabilities, chooser, shareWith); } public synchronized void invokeGL(final Runnable runnable, boolean isReshape, Runnable initAction) throws GLException { @@ -121,12 +124,19 @@ public class MacOSXOnscreenGLContext extends MacOSXGLContext { } protected void create() { - nsContext = CGL.createContext(nsView); + 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(nsView, share); if (nsContext == 0) { throw new GLException("Error creating nsContext"); } - // FIXME - //choosePixelFormatAndCreateContext(true); + GLContextShareSet.contextCreated(this); } protected synchronized boolean makeCurrent(Runnable initAction) throws GLException { |