aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/games/jogl/impl/windows
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2003-07-08 09:20:04 +0000
committerKenneth Russel <[email protected]>2003-07-08 09:20:04 +0000
commit4f936be964c9e8613a5e43e1d88490ff7f550ec9 (patch)
tree74a2c01c6093d89ac123d08642b11a2007cc99e2 /src/net/java/games/jogl/impl/windows
parent93d272a0525ec57aa3cd584f15cde6cf2a637e0c (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')
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsGLContext.java31
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java7
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsOffscreenGLContext.java7
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java7
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java2
5 files changed, 43 insertions, 11 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() +
diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java b/src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java
index 15e622efb..cfad54025 100644
--- a/src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java
+++ b/src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java
@@ -46,11 +46,12 @@ import net.java.games.jogl.impl.*;
public class WindowsGLContextFactory extends GLContextFactory {
public GLContext createGLContext(Component component,
GLCapabilities capabilities,
- GLCapabilitiesChooser chooser) {
+ GLCapabilitiesChooser chooser,
+ GLContext shareWith) {
if (component != null) {
- return new WindowsOnscreenGLContext(component, capabilities, chooser);
+ return new WindowsOnscreenGLContext(component, capabilities, chooser, shareWith);
} else {
- return new WindowsOffscreenGLContext(capabilities, chooser);
+ return new WindowsOffscreenGLContext(capabilities, chooser, shareWith);
}
}
}
diff --git a/src/net/java/games/jogl/impl/windows/WindowsOffscreenGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsOffscreenGLContext.java
index 727517e63..e26060b65 100644
--- a/src/net/java/games/jogl/impl/windows/WindowsOffscreenGLContext.java
+++ b/src/net/java/games/jogl/impl/windows/WindowsOffscreenGLContext.java
@@ -50,8 +50,10 @@ public class WindowsOffscreenGLContext extends WindowsGLContext {
private int width;
private int height;
- public WindowsOffscreenGLContext(GLCapabilities capabilities, GLCapabilitiesChooser chooser) {
- super(null, capabilities, chooser);
+ public WindowsOffscreenGLContext(GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser,
+ GLContext shareWith) {
+ super(null, capabilities, chooser, shareWith);
}
protected GL createGL()
@@ -165,5 +167,6 @@ public class WindowsOffscreenGLContext extends WindowsGLContext {
origbitmap = 0;
hbitmap = 0;
hdc = 0;
+ GLContextShareSet.contextDestroyed(this);
}
}
diff --git a/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java
index a5b7519cf..d97cded65 100644
--- a/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java
+++ b/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java
@@ -54,8 +54,11 @@ public class WindowsOnscreenGLContext extends WindowsGLContext {
// Variables for pbuffer support
List pbuffersToInstantiate = new ArrayList();
- public WindowsOnscreenGLContext(Component component, GLCapabilities capabilities, GLCapabilitiesChooser chooser) {
- super(component, capabilities, chooser);
+ public WindowsOnscreenGLContext(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/windows/WindowsPbufferGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java
index 484c8f8af..18e954b2a 100644
--- a/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java
+++ b/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java
@@ -67,7 +67,7 @@ public class WindowsPbufferGLContext extends WindowsGLContext {
private int texture; // actual texture object
public WindowsPbufferGLContext(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) {