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/x11 | |
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/x11')
5 files changed, 41 insertions, 13 deletions
diff --git a/src/net/java/games/jogl/impl/x11/X11GLContext.java b/src/net/java/games/jogl/impl/x11/X11GLContext.java index ec430bfe8..3fb142bff 100644 --- a/src/net/java/games/jogl/impl/x11/X11GLContext.java +++ b/src/net/java/games/jogl/impl/x11/X11GLContext.java @@ -65,8 +65,11 @@ public abstract class X11GLContext extends GLContext { functionNameMap.put("glFreeMemoryNV", "glXFreeMemoryNV"); } - public X11GLContext(Component component, GLCapabilities capabilities, GLCapabilitiesChooser chooser) { - super(component, capabilities, chooser); + public X11GLContext(Component component, + GLCapabilities capabilities, + GLCapabilitiesChooser chooser, + GLContext shareWith) { + super(component, capabilities, chooser, shareWith); } protected GL createGL() @@ -162,6 +165,10 @@ public abstract class X11GLContext extends GLContext { return res; } + public boolean isCreated() { + return (context != 0); + } + protected void resetGLFunctionAvailability() { super.resetGLFunctionAvailability(); if (DEBUG) { @@ -287,20 +294,34 @@ public abstract class X11GLContext extends GLContext { } protected long createContext(XVisualInfo vis, boolean onscreen) { - // FIXME: support sharing of display lists between contexts - return GLX.glXCreateContext(display, vis, 0, onscreen); + X11GLContext other = (X11GLContext) GLContextShareSet.getShareContext(this); + long share = 0; + if (other != null) { + share = other.getContext(); + if (share == 0) { + throw new GLException("GLContextShareSet returned an invalid OpenGL context"); + } + } + long res = GLX.glXCreateContext(display, vis, share, onscreen); + if (res != 0) { + GLContextShareSet.contextCreated(this); + } + return res; } // Helper routine for the overridden create() to call protected void chooseVisualAndCreateContext(boolean onscreen) { XVisualInfo vis = chooseVisual(); - // FIXME: support sharing of display lists between contexts context = createContext(vis, onscreen); if (context == 0) { throw new GLException("Unable to create OpenGL context"); } } + protected long getContext() { + return context; + } + protected int[] glCapabilities2AttribList(GLCapabilities caps) { int colorDepth = (caps.getRedBits() + caps.getGreenBits() + diff --git a/src/net/java/games/jogl/impl/x11/X11GLContextFactory.java b/src/net/java/games/jogl/impl/x11/X11GLContextFactory.java index cf1e4be25..5a8298753 100644 --- a/src/net/java/games/jogl/impl/x11/X11GLContextFactory.java +++ b/src/net/java/games/jogl/impl/x11/X11GLContextFactory.java @@ -46,11 +46,12 @@ import net.java.games.jogl.impl.*; public class X11GLContextFactory extends GLContextFactory { public GLContext createGLContext(Component component, GLCapabilities capabilities, - GLCapabilitiesChooser chooser) { + GLCapabilitiesChooser chooser, + GLContext shareWith) { if (component != null) { - return new X11OnscreenGLContext(component, capabilities, chooser); + return new X11OnscreenGLContext(component, capabilities, chooser, shareWith); } else { - return new X11OffscreenGLContext(capabilities, chooser); + return new X11OffscreenGLContext(capabilities, chooser, shareWith); } } } diff --git a/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java b/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java index 62fd380ee..727c8f23d 100644 --- a/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java +++ b/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java @@ -53,8 +53,10 @@ public class X11OffscreenGLContext extends X11GLContext { // Display connection for use by all offscreen surfaces private long staticDisplay; - public X11OffscreenGLContext(GLCapabilities capabilities, GLCapabilitiesChooser chooser) { - super(null, capabilities, chooser); + public X11OffscreenGLContext(GLCapabilities capabilities, + GLCapabilitiesChooser chooser, + GLContext shareWith) { + super(null, capabilities, chooser, shareWith); } protected GL createGL() @@ -173,5 +175,6 @@ public class X11OffscreenGLContext extends X11GLContext { context = 0; drawable = 0; pixmap = 0; + GLContextShareSet.contextDestroyed(this); } } diff --git a/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java b/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java index 385874da7..882e9b3f1 100644 --- a/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java +++ b/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java @@ -54,8 +54,11 @@ public class X11OnscreenGLContext extends X11GLContext { // Variables for pbuffer support List pbuffersToInstantiate = new ArrayList(); - public X11OnscreenGLContext(Component component, GLCapabilities capabilities, GLCapabilitiesChooser chooser) { - super(component, capabilities, chooser); + public X11OnscreenGLContext(Component component, + GLCapabilities capabilities, + GLCapabilitiesChooser chooser, + GLContext shareWith) { + super(component, capabilities, chooser, shareWith); } protected GL createGL() diff --git a/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java b/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java index 264d60fc7..c92eba96f 100644 --- a/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java +++ b/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java @@ -65,7 +65,7 @@ public class X11PbufferGLContext extends X11GLContext { // it looks like floating-point buffers are not) public X11PbufferGLContext(GLCapabilities capabilities, int initialWidth, int initialHeight) { - super(null, capabilities, null); + super(null, capabilities, null, null); this.initWidth = initialWidth; this.initHeight = initialHeight; if (initWidth <= 0 || initHeight <= 0) { |