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/windows/WindowsGLContext.java | |
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/windows/WindowsGLContext.java')
-rw-r--r-- | src/net/java/games/jogl/impl/windows/WindowsGLContext.java | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java index 5a6021acf..44ff97ffc 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java +++ b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java @@ -69,8 +69,11 @@ public abstract class WindowsGLContext extends GLContext { extensionNameMap.put("GL_ARB_pixel_format", "WGL_ARB_pixel_format"); } - public WindowsGLContext(Component component, GLCapabilities capabilities, GLCapabilitiesChooser chooser) { - super(component, capabilities, chooser); + public WindowsGLContext(Component component, + GLCapabilities capabilities, + GLCapabilitiesChooser chooser, + GLContext shareWith) { + super(component, capabilities, chooser, shareWith); } protected GL createGL() @@ -103,7 +106,7 @@ public abstract class WindowsGLContext extends GLContext { public abstract boolean offscreenImageNeedsVerticalFlip(); /** - * Creates and initializes an appropriate OpenGl context. Should only be + * Creates and initializes an appropriate OpenGL context. Should only be * called by {@link makeCurrent(Runnable)}. */ protected abstract void create(); @@ -124,6 +127,20 @@ public abstract class WindowsGLContext extends GLContext { if (created) { resetGLFunctionAvailability(); + // Windows can set up sharing of display lists after creation time + WindowsGLContext other = (WindowsGLContext) GLContextShareSet.getShareContext(this); + if (other != null) { + long hglrc2 = other.getHGLRC(); + if (hglrc2 == 0) { + throw new GLException("GLContextShareSet returned an invalid OpenGL context"); + } + if (!WGL.wglShareLists(hglrc2, hglrc)) { + throw new GLException("wglShareLists(0x" + Long.toHexString(hglrc2) + + ", 0x" + Long.toHexString(hglrc) + ") failed"); + } + } + GLContextShareSet.contextCreated(this); + initAction.run(); } return true; @@ -152,6 +169,10 @@ public abstract class WindowsGLContext extends GLContext { return res; } + public boolean isCreated() { + return (hglrc != 0); + } + protected void resetGLFunctionAvailability() { super.resetGLFunctionAvailability(); if (DEBUG) { @@ -270,6 +291,10 @@ public abstract class WindowsGLContext extends GLContext { } } + protected long getHGLRC() { + return hglrc; + } + static PIXELFORMATDESCRIPTOR glCapabilities2PFD(GLCapabilities caps, boolean onscreen) { int colorDepth = (caps.getRedBits() + caps.getGreenBits() + |