diff options
Diffstat (limited to 'src/jogl/classes/javax/media/opengl/awt')
-rw-r--r-- | src/jogl/classes/javax/media/opengl/awt/GLCanvas.java | 48 | ||||
-rw-r--r-- | src/jogl/classes/javax/media/opengl/awt/GLJPanel.java | 6 |
2 files changed, 38 insertions, 16 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index be42e1da1..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; @@ -396,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); @@ -538,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 61e1429b6..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 @@ -469,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; } |