summaryrefslogtreecommitdiffstats
path: root/src/net/java/games/jogl/impl/windows
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/java/games/jogl/impl/windows')
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsGLContext.java15
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java35
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java9
3 files changed, 47 insertions, 12 deletions
diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java
index 56a7188eb..d58a781a8 100644
--- a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java
+++ b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java
@@ -168,6 +168,18 @@ public abstract class WindowsGLContext extends GLContext {
}
}
+ protected void destroyImpl() throws GLException {
+ if (hglrc != 0) {
+ if (!WGL.wglDeleteContext(hglrc)) {
+ throw new GLException("Unable to delete OpenGL context");
+ }
+ if (DEBUG) {
+ System.err.println("!!! Destroyed OpenGL context " + hglrc);
+ }
+ hglrc = 0;
+ }
+ }
+
public abstract void swapBuffers() throws GLException;
protected long dynamicLookupFunction(String glFuncName) {
@@ -455,6 +467,9 @@ public abstract class WindowsGLContext extends GLContext {
throw new GLException("Unable to set pixel format");
}
hglrc = WGL.wglCreateContext(hdc);
+ if (DEBUG) {
+ System.err.println("!!! Created OpenGL context " + hglrc);
+ }
if (hglrc == 0) {
throw new GLException("Unable to create OpenGL context");
}
diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java b/src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java
index 961a116d8..74d72645d 100644
--- a/src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java
+++ b/src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java
@@ -101,10 +101,10 @@ public class WindowsGLContextFactory extends GLContextFactory {
GraphicsConfiguration config = device.getDefaultConfiguration();
final Dialog frame = new Dialog(new Frame(config), "", false, config);
frame.setUndecorated(true);
- GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities(),
- null,
- null,
- device);
+ final GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities(),
+ null,
+ null,
+ device);
canvas.addGLEventListener(new GLEventListener() {
public void init(GLDrawable drawable) {
pendingContextSet.remove(device);
@@ -133,16 +133,29 @@ public class WindowsGLContextFactory extends GLContextFactory {
public void reshape(GLDrawable drawable, int x, int y, int width, int height) {
}
+ public void destroy(GLDrawable drawable) {
+ }
+
public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged) {
}
});
- canvas.setSize(0, 0);
- canvas.setNoAutoRedrawMode(true);
- canvas.setAutoSwapBufferMode(false);
- frame.add(canvas);
- frame.pack();
- frame.show();
- canvas.display();
+ // Attempt to work around deadlock issues with SingleThreadedWorkaround,
+ // which causes some of the methods below to block doing work on the AWT thread
+ try {
+ EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ canvas.setSize(0, 0);
+ canvas.setNoAutoRedrawMode(true);
+ canvas.setAutoSwapBufferMode(false);
+ frame.add(canvas);
+ frame.pack();
+ frame.show();
+ canvas.display();
+ }
+ });
+ } catch (Exception e) {
+ throw new GLException(e);
+ }
}
return (GL) dummyContextMap.get(device);
diff --git a/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java
index 868846079..5bcdb4559 100644
--- a/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java
+++ b/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java
@@ -155,12 +155,19 @@ public class WindowsOnscreenGLContext extends WindowsGLContext {
throw new GLException("Unable to lock surface");
}
// See whether the surface changed and if so destroy the old
- // OpenGL context so it will be recreated
+ // OpenGL context so it will be recreated (NOTE: removeNotify
+ // should handle this case, but it may be possible that race
+ // conditions can cause this code to be triggered -- should test
+ // more)
if ((res & JAWTFactory.JAWT_LOCK_SURFACE_CHANGED) != 0) {
if (hglrc != 0) {
if (!WGL.wglDeleteContext(hglrc)) {
throw new GLException("Unable to delete old GL context after surface changed");
}
+ GLContextShareSet.contextDestroyed(this);
+ if (DEBUG) {
+ System.err.println("!!! Destroyed OpenGL context " + hglrc + " due to JAWT_LOCK_SURFACE_CHANGED");
+ }
hglrc = 0;
}
}