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.java22
-rw-r--r--src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java16
-rw-r--r--src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java46
-rw-r--r--src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java10
4 files changed, 55 insertions, 39 deletions
diff --git a/src/net/java/games/jogl/impl/x11/X11GLContext.java b/src/net/java/games/jogl/impl/x11/X11GLContext.java
index 837b7b791..7077c855e 100644
--- a/src/net/java/games/jogl/impl/x11/X11GLContext.java
+++ b/src/net/java/games/jogl/impl/x11/X11GLContext.java
@@ -46,7 +46,7 @@ import net.java.games.gluegen.runtime.*; // for PROCADDRESS_VAR_PREFIX
import net.java.games.jogl.*;
import net.java.games.jogl.impl.*;
-public abstract class X11GLContext extends GLContext {
+public abstract class X11GLContext extends GLContextImpl {
protected long display;
protected long drawable;
protected long visualID;
@@ -126,19 +126,9 @@ public abstract class X11GLContext extends GLContext {
public abstract boolean offscreenImageNeedsVerticalFlip();
- public synchronized void setRenderingThread(Thread currentThreadOrNull, Runnable initAction) {
- this.willSetRenderingThread = false;
- // FIXME: the JAWT on X11 grabs the AWT lock while the
- // DrawingSurface is locked, which means that no other events can
- // be processed. Currently we handle this by preventing the
- // effects of setRenderingThread. We should figure out a better
- // solution that is reasonably robust. Must file a bug to be fixed
- // in the 1.5 JAWT.
- }
-
/**
* Creates and initializes an appropriate OpenGl context. Should only be
- * called by {@link makeCurrent(Runnable)}.
+ * called by {@link makeCurrentImpl()}.
*/
protected abstract void create();
@@ -150,7 +140,7 @@ public abstract class X11GLContext extends GLContext {
return super.isExtensionAvailable(glExtensionName);
}
- protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
+ protected int makeCurrentImpl() throws GLException {
boolean created = false;
if (context == 0) {
create();
@@ -172,12 +162,12 @@ public abstract class X11GLContext extends GLContext {
if (created) {
resetGLFunctionAvailability();
- initAction.run();
+ return CONTEXT_CURRENT_NEW;
}
- return true;
+ return CONTEXT_CURRENT;
}
- protected synchronized void free() throws GLException {
+ protected void releaseImpl() throws GLException {
if (!GLX.glXMakeCurrent(display, 0, 0)) {
throw new GLException("Error freeing OpenGL context");
}
diff --git a/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java b/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java
index 2e30e2b18..c493d3380 100644
--- a/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java
+++ b/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java
@@ -95,9 +95,9 @@ public class X11OffscreenGLContext extends X11GLContext {
return false;
}
- public synchronized GLContext createPbufferContext(GLCapabilities capabilities,
- int initialWidth,
- int initialHeight) {
+ public GLContext createPbufferContext(GLCapabilities capabilities,
+ int initialWidth,
+ int initialHeight) {
throw new GLException("Not supported");
}
@@ -109,7 +109,7 @@ public class X11OffscreenGLContext extends X11GLContext {
throw new GLException("Should not call this");
}
- protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
+ protected int makeCurrentImpl() throws GLException {
display = X11GLContextFactory.getDisplayConnection();
if (pendingOffscreenResize) {
if (pendingOffscreenWidth != width || pendingOffscreenHeight != height) {
@@ -122,15 +122,15 @@ public class X11OffscreenGLContext extends X11GLContext {
}
}
mostRecentDisplay = display;
- return super.makeCurrent(initAction);
+ return super.makeCurrentImpl();
}
- public synchronized void swapBuffers() throws GLException {
+ public void swapBuffers() throws GLException {
}
- protected synchronized void free() throws GLException {
+ protected void releaseImpl() throws GLException {
try {
- super.free();
+ super.releaseImpl();
} finally {
display = 0;
}
diff --git a/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java b/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java
index 2fd340d79..5a6fe23bb 100644
--- a/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java
+++ b/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java
@@ -51,6 +51,18 @@ public class X11OnscreenGLContext extends X11GLContext {
private JAWT_DrawingSurfaceInfo dsi;
private JAWT_X11DrawingSurfaceInfo x11dsi;
+ // Indicates whether the component (if an onscreen context) has been
+ // realized. Plausibly, before the component is realized the JAWT
+ // should return an error or NULL object from some of its
+ // operations; this appears to be the case on Win32 but is not true
+ // at least with Sun's current X11 implementation (1.4.x), which
+ // crashes with no other error reported if the DrawingSurfaceInfo is
+ // fetched from a locked DrawingSurface during the validation as a
+ // result of calling show() on the main thread. To work around this
+ // we prevent any JAWT or OpenGL operations from being done until
+ // addNotify() is called on the component.
+ protected boolean realized;
+
// Variables for pbuffer support
List pbuffersToInstantiate = new ArrayList();
@@ -83,10 +95,11 @@ public class X11OnscreenGLContext extends X11GLContext {
return true;
}
- public synchronized GLContext createPbufferContext(GLCapabilities capabilities,
- int initialWidth,
- int initialHeight) {
+ public GLContext createPbufferContext(GLCapabilities capabilities,
+ int initialWidth,
+ int initialHeight) {
X11PbufferGLContext ctx = new X11PbufferGLContext(capabilities, initialWidth, initialHeight);
+ ctx.setSynchronized(true);
pbuffersToInstantiate.add(ctx);
return ctx;
}
@@ -106,13 +119,21 @@ public class X11OnscreenGLContext extends X11GLContext {
}
}
- protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
+ public void setRealized() {
+ realized = true;
+ }
+
+ protected int makeCurrentImpl() throws GLException {
try {
+ if (!realized) {
+ return CONTEXT_NOT_CURRENT;
+ }
if (!lockSurface()) {
- return false;
+ return CONTEXT_NOT_CURRENT;
}
- boolean ret = super.makeCurrent(initAction);
- if (ret) {
+ int ret = super.makeCurrentImpl();
+ if ((ret == CONTEXT_CURRENT) ||
+ (ret == CONTEXT_CURRENT_NEW)) {
// Instantiate any pending pbuffers
while (!pbuffersToInstantiate.isEmpty()) {
X11PbufferGLContext ctx =
@@ -131,15 +152,20 @@ public class X11OnscreenGLContext extends X11GLContext {
}
}
- protected synchronized void free() throws GLException {
+ protected void releaseImpl() throws GLException {
try {
- super.free();
+ super.releaseImpl();
} finally {
unlockSurface();
}
}
- public synchronized void swapBuffers() throws GLException {
+ protected void destroyImpl() throws GLException {
+ realized = false;
+ super.destroyImpl();
+ }
+
+ public void swapBuffers() throws GLException {
// FIXME: this cast to int would be wrong on 64-bit platforms
// where the argument type to glXMakeCurrent would change (should
// probably make GLXDrawable, and maybe XID, Opaque as long)
diff --git a/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java b/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java
index 7733472fb..30a60ba61 100644
--- a/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java
+++ b/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java
@@ -234,10 +234,10 @@ public class X11PbufferGLContext extends X11GLContext {
}
}
- protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
+ protected int makeCurrentImpl() throws GLException {
if (buffer == 0) {
// pbuffer not instantiated yet
- return false;
+ return CONTEXT_NOT_CURRENT;
}
lockAWT();
@@ -257,15 +257,15 @@ public class X11PbufferGLContext extends X11GLContext {
if (created) {
resetGLFunctionAvailability();
- initAction.run();
+ return CONTEXT_CURRENT_NEW;
}
- return true;
+ return CONTEXT_CURRENT;
} finally {
unlockAWT();
}
}
- protected synchronized void free() throws GLException {
+ protected void releaseImpl() throws GLException {
lockAWT();
try {
if (!GLX.glXMakeContextCurrent(display, 0, 0, 0)) {