aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/games/jogl/impl/windows
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2005-07-10 23:17:43 +0000
committerKenneth Russel <[email protected]>2005-07-10 23:17:43 +0000
commit8a4e964a88703bcab4a8888b25ea9e997953180a (patch)
tree073e1a11d44a0f4cb407419c90f89aee0979403d /src/net/java/games/jogl/impl/windows
parent6e8dd12319e2d6f702cf66728b177e6ea0152c2c (diff)
Initial set of context-related changes for the JSR-231 API. GLContext
has been exposed in the public API. The GLEventListener callback mechanism has been removed from the core GLContext implementation and moved up to a higher level. GLAutoDrawable now contains the GLEventListener-related methods, and the GLEventListener's methods now receive a GLAutoDrawable as argument. All JOGL demos have been updated for the new APIs. Many FIXMEs and much unimplemented functionality remain. There is slightly different initialization behavior for the demos containing pbuffers, and the deferring of reshape callbacks needs to be rethought. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JSR-231@320 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.java13
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsOffscreenGLContext.java12
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java48
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java6
4 files changed, 53 insertions, 26 deletions
diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java
index e938c8023..338b11e6a 100644
--- a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java
+++ b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java
@@ -48,7 +48,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 WindowsGLContext extends GLContext {
+public abstract class WindowsGLContext extends GLContextImpl {
private static JAWT jawt;
protected long hglrc;
protected long hdc;
@@ -124,11 +124,11 @@ public abstract class WindowsGLContext extends GLContext {
/**
* Creates and initializes an appropriate OpenGL context. Should only be
- * called by {@link #makeCurrent(Runnable)}.
+ * called by {@link #makeCurrentImpl()}.
*/
protected abstract void create();
- protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
+ protected int makeCurrentImpl() throws GLException {
boolean created = false;
if (hglrc == 0) {
create();
@@ -177,13 +177,12 @@ public abstract class WindowsGLContext extends GLContext {
}
}
GLContextShareSet.contextCreated(this);
-
- initAction.run();
+ return CONTEXT_CURRENT_NEW;
}
- return true;
+ return CONTEXT_CURRENT;
}
- protected synchronized void free() throws GLException {
+ protected void releaseImpl() throws GLException {
if (!NO_FREE) {
if (!WGL.wglMakeCurrent(0, 0)) {
throw new GLException("Error freeing OpenGL context: " + WGL.GetLastError());
diff --git a/src/net/java/games/jogl/impl/windows/WindowsOffscreenGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsOffscreenGLContext.java
index c70607da7..d944a8684 100644
--- a/src/net/java/games/jogl/impl/windows/WindowsOffscreenGLContext.java
+++ b/src/net/java/games/jogl/impl/windows/WindowsOffscreenGLContext.java
@@ -92,9 +92,9 @@ public class WindowsOffscreenGLContext extends WindowsGLContext {
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");
}
@@ -106,7 +106,7 @@ public class WindowsOffscreenGLContext extends WindowsGLContext {
throw new GLException("Should not call this");
}
- protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
+ protected int makeCurrentImpl() throws GLException {
if (pendingOffscreenResize) {
if (pendingOffscreenWidth != width || pendingOffscreenHeight != height) {
if (hglrc != 0) {
@@ -117,7 +117,7 @@ public class WindowsOffscreenGLContext extends WindowsGLContext {
pendingOffscreenResize = false;
}
}
- return super.makeCurrent(initAction);
+ return super.makeCurrentImpl();
}
protected void destroyImpl() {
@@ -133,7 +133,7 @@ public class WindowsOffscreenGLContext extends WindowsGLContext {
}
}
- public synchronized void swapBuffers() throws GLException {
+ public void swapBuffers() throws GLException {
}
protected void create() {
diff --git a/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java
index 0dc1818fb..d4af4b3b7 100644
--- a/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java
+++ b/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java
@@ -51,6 +51,18 @@ public class WindowsOnscreenGLContext extends WindowsGLContext {
JAWT_DrawingSurfaceInfo dsi;
JAWT_Win32DrawingSurfaceInfo win32dsi;
+ // 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();
@@ -61,6 +73,7 @@ public class WindowsOnscreenGLContext extends WindowsGLContext {
super(component, capabilities, chooser, shareWith);
}
+ /*
public void invokeGL(Runnable runnable, boolean isReshape, Runnable initAction) throws GLException {
// Unfortunately, invokeGL can be called with the AWT tree lock
// held, and the Windows onscreen implementation of
@@ -79,6 +92,7 @@ public class WindowsOnscreenGLContext extends WindowsGLContext {
super.invokeGL(runnable, isReshape, initAction);
}
}
+ */
protected GL createGL()
{
@@ -101,10 +115,11 @@ public class WindowsOnscreenGLContext extends WindowsGLContext {
return haveWGLARBPbuffer();
}
- public synchronized GLContext createPbufferContext(GLCapabilities capabilities,
- int initialWidth,
- int initialHeight) {
+ public GLContext createPbufferContext(GLCapabilities capabilities,
+ int initialWidth,
+ int initialHeight) {
WindowsPbufferGLContext ctx = new WindowsPbufferGLContext(capabilities, initialWidth, initialHeight);
+ ctx.setSynchronized(true);
pbuffersToInstantiate.add(ctx);
return ctx;
}
@@ -117,13 +132,21 @@ public class WindowsOnscreenGLContext extends WindowsGLContext {
throw new GLException("Should not call this");
}
- 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()) {
WindowsPbufferGLContext ctx =
@@ -142,15 +165,20 @@ public class WindowsOnscreenGLContext extends WindowsGLContext {
}
}
- 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 {
if (!WGL.SwapBuffers(hdc) && (WGL.GetLastError() != 0)) {
throw new GLException("Error swapping buffers");
}
diff --git a/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java
index 26108a5cd..d58d15d02 100644
--- a/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java
+++ b/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java
@@ -382,7 +382,7 @@ public class WindowsPbufferGLContext extends WindowsGLContext {
}
}
- protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
+ protected int makeCurrentImpl() throws GLException {
created = false;
if (buffer == 0) {
@@ -390,10 +390,10 @@ public class WindowsPbufferGLContext extends WindowsGLContext {
if (DEBUG) {
System.err.println("pbuffer not instantiated yet");
}
- return false;
+ return CONTEXT_NOT_CURRENT;
}
- boolean res = super.makeCurrent(initAction);
+ int res = super.makeCurrentImpl();
if (DEBUG) {
System.err.println("super.makeCurrent() = " + res + ", created = " + created);
}