aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/games/jogl/impl/x11
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/java/games/jogl/impl/x11')
-rw-r--r--src/net/java/games/jogl/impl/x11/X11GLContext.java31
-rw-r--r--src/net/java/games/jogl/impl/x11/X11GLContextFactory.java7
-rw-r--r--src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java7
-rw-r--r--src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java7
-rw-r--r--src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java2
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) {