summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax/media/opengl/awt
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-06-10 14:28:03 +0200
committerMichael Bien <[email protected]>2010-06-10 14:28:03 +0200
commit2522d4f1ebffec030d7e8c3688e5f952c574c3d0 (patch)
tree81d631cb11dadc483a4615996dedf773eed083da /src/jogl/classes/javax/media/opengl/awt
parent57d3d3f9f9475ae167cd9d33c9450eea66439fd2 (diff)
parent1d333a771ce0bc7c8594e21d031703f698f06a46 (diff)
Merge branch 'master' of github.com:sgothel/jogl
Diffstat (limited to 'src/jogl/classes/javax/media/opengl/awt')
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java56
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java14
2 files changed, 48 insertions, 22 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 9932f0cf9..77b8e45d3 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -44,6 +44,7 @@ import javax.media.nativewindow.*;
import javax.media.nativewindow.awt.*;
import com.jogamp.opengl.impl.*;
+import com.jogamp.nativewindow.impl.jawt.JAWTUtil;
import java.awt.Canvas;
import java.awt.Color;
@@ -73,9 +74,15 @@ import java.security.*;
public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
- private static final boolean DEBUG = Debug.debug("GLCanvas");
+ private static final boolean DEBUG;
+ private static final GLProfile defaultGLProfile;
+
+ static {
+ NativeWindowFactory.initSingleton();
+ defaultGLProfile = GLProfile.getDefault();
+ DEBUG = Debug.debug("GLCanvas");
+ }
- static private GLProfile defaultGLProfile = GLProfile.getDefault();
private GLProfile glProfile;
private GLDrawableHelper drawableHelper = new GLDrawableHelper();
private GraphicsConfiguration chosen;
@@ -320,11 +327,13 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
// The user really should not be invoking remove() from this
// thread -- but since he/she is, we can not go over to the
// EDT at this point. Try to destroy the context from here.
- drawableHelper.invokeGL(drawable, context, disposeAction, null);
- } else {
+ if(context.isCreated()) {
+ drawableHelper.invokeGL(drawable, context, disposeAction, null);
+ }
+ } else if(context.isCreated()) {
Threading.invokeOnOpenGLThread(disposeOnEventDispatchThreadAction);
}
- } else {
+ } else if(context.isCreated()) {
drawableHelper.invokeGL(drawable, context, disposeAction, null);
}
@@ -394,22 +403,27 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
/*
* Save the chosen capabilities for use in getGraphicsConfiguration().
*/
- awtConfig = chooseGraphicsConfiguration(capabilities, chooser, device);
- if(DEBUG) {
- Exception e = new Exception("Created Config: "+awtConfig);
- e.printStackTrace();
- }
- if(null!=awtConfig) {
- // update ..
- chosen = awtConfig.getGraphicsConfiguration();
+ JAWTUtil.lockToolkit();
+ try {
+ awtConfig = chooseGraphicsConfiguration(capabilities, chooser, device);
+ if(DEBUG) {
+ Exception e = new Exception("Created Config: "+awtConfig);
+ e.printStackTrace();
+ }
+ if(null!=awtConfig) {
+ // update ..
+ chosen = awtConfig.getGraphicsConfiguration();
+ }
+ if(null==awtConfig) {
+ throw new GLException("Error: AWTGraphicsConfiguration is null");
+ }
+ drawable = GLDrawableFactory.getFactory(glProfile).createGLDrawable(NativeWindowFactory.getNativeWindow(this, awtConfig));
+ context = (GLContextImpl) drawable.createContext(shareWith);
+ context.setSynchronized(true);
+ } finally {
+ JAWTUtil.unlockToolkit();
}
- if(null==awtConfig) {
- throw new GLException("Error: AWTGraphicsConfiguration is null");
- }
- drawable = GLDrawableFactory.getFactory(glProfile).createGLDrawable(NativeWindowFactory.getNativeWindow(this, awtConfig));
- context = (GLContextImpl) drawable.createContext(shareWith);
- context.setSynchronized(true);
if(DEBUG) {
System.err.println("Created Drawable: "+drawable);
@@ -536,6 +550,10 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
return drawable.getNativeWindow();
}
+ public long getHandle() {
+ return drawable.getHandle();
+ }
+
public GLDrawableFactory getFactory() {
return drawable.getFactory();
}
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index eb8c68263..955949415 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -137,6 +137,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
private int viewportY;
static {
+ NativeWindowFactory.initSingleton();
+
// Force eager initialization of part of the Java2D class since
// otherwise it's likely it will try to be initialized while on
// the Queue Flusher Thread, which is not allowed
@@ -227,11 +229,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
// The user really should not be invoking remove() from this
// thread -- but since he/she is, we can not go over to the
// EDT at this point. Try to destroy the context from here.
- drawableHelper.invokeGL(disposeDrawable, disposeContext, disposeAction, null);
- } else {
+ if(disposeContext.isCreated()) {
+ drawableHelper.invokeGL(disposeDrawable, disposeContext, disposeAction, null);
+ }
+ } else if(disposeContext.isCreated()) {
Threading.invokeOnOpenGLThread(disposeOnEventDispatchThreadAction);
}
- } else {
+ } else if(disposeContext.isCreated()) {
drawableHelper.invokeGL(disposeDrawable, disposeContext, disposeAction, null);
}
@@ -467,6 +471,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
throw new GLException("FIXME");
}
+ public long getHandle() {
+ throw new GLException("FIXME");
+ }
+
public final GLDrawableFactory getFactory() {
return factory;
}