summaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java98
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java44
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java6
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLWorkerThread.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/awt/AWTUtil.java5
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/awt/Java2D.java10
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java10
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java7
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java12
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java5
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java6
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java5
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java7
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java15
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java15
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java8
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java6
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java6
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java129
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java16
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java10
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXDrawable.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java8
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java10
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java4
-rw-r--r--src/jogl/classes/javax/media/opengl/GLPipelineFactory.java4
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java108
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java23
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java18
34 files changed, 361 insertions, 254 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
index 219d9f4dd..3d4c601fe 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
@@ -122,7 +122,7 @@ public abstract class GLContextImpl extends GLContext {
if(DEBUG) {
String sgl1 = (null!=this.gl)?this.gl.getClass().toString()+", "+this.gl.toString():"<null>";
String sgl2 = (null!=gl)?gl.getClass().toString()+", "+gl.toString():"<null>";
- Exception e = new Exception("setGL (OpenGL "+getGLVersion()+"): "+Thread.currentThread()+", "+sgl1+" -> "+sgl2);
+ Exception e = new Exception("Info: setGL (OpenGL "+getGLVersion()+"): "+Thread.currentThread()+", "+sgl1+" -> "+sgl2);
e.printStackTrace();
}
this.gl = gl;
@@ -1053,7 +1053,7 @@ public abstract class GLContextImpl extends GLContext {
e.printStackTrace();
// FIXME: refactor desktop OpenGL dependencies and make this
// class work properly for OpenGL ES
- System.err.println("ExtensionAvailabilityCache: FunctionAvailabilityCache.Version.<init>: "+e);
+ System.err.println("Info: ExtensionAvailabilityCache: FunctionAvailabilityCache.Version.<init>: "+e);
major = 1;
minor = 0;
/*
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
index 1cde00102..c0e554889 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
@@ -69,28 +69,34 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
}
AbstractGraphicsConfiguration config = target.getGraphicsConfiguration().getNativeGraphicsConfiguration();
GLCapabilities caps = (GLCapabilities) config.getChosenCapabilities();
+ AbstractGraphicsDevice adevice = config.getScreen().getDevice();
GLDrawable result = null;
- if(caps.isOnscreen()) {
- if(DEBUG) {
- System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OnscreenDrawable: "+target);
- }
- result = createOnscreenDrawable(target);
- } else {
- if( ! ( target instanceof SurfaceChangeable ) ) {
- throw new IllegalArgumentException("Passed NativeSurface must implement SurfaceChangeable for offscreen: "+target);
- }
- if(caps.isPBuffer()) {
+ adevice.lock();
+ try {
+ if(caps.isOnscreen()) {
if(DEBUG) {
- System.err.println("GLDrawableFactoryImpl.createGLDrawable -> PbufferDrawable: "+target);
+ System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OnscreenDrawable: "+target);
}
- result = createGLPbufferDrawable(target);
- }
- if(null==result) {
- if(DEBUG) {
- System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OffScreenDrawable: "+target);
+ result = createOnscreenDrawableImpl(target);
+ } else {
+ if( ! ( target instanceof SurfaceChangeable ) ) {
+ throw new IllegalArgumentException("Passed NativeSurface must implement SurfaceChangeable for offscreen: "+target);
+ }
+ if(caps.isPBuffer() && canCreateGLPbuffer(adevice)) {
+ if(DEBUG) {
+ System.err.println("GLDrawableFactoryImpl.createGLDrawable -> PbufferDrawable: "+target);
+ }
+ result = createGLPbufferDrawable(target);
+ }
+ if(null==result) {
+ if(DEBUG) {
+ System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OffScreenDrawable: "+target);
+ }
+ result = createOffscreenDrawableImpl(target);
}
- result = createOffscreenDrawable(target);
}
+ } finally {
+ adevice.unlock();
}
if(DEBUG) {
System.err.println("GLDrawableFactoryImpl.createGLDrawable: "+result);
@@ -103,23 +109,25 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
// Onscreen GLDrawable construction
//
- protected abstract GLDrawableImpl createOnscreenDrawable(NativeSurface target);
+ protected abstract GLDrawableImpl createOnscreenDrawableImpl(NativeSurface target);
//---------------------------------------------------------------------------
//
// PBuffer GLDrawable construction
//
+ public abstract boolean canCreateGLPbuffer(AbstractGraphicsDevice device);
+
/** Target must implement SurfaceChangeable */
protected abstract GLDrawableImpl createGLPbufferDrawableImpl(NativeSurface target);
- protected GLDrawableImpl createGLPbufferDrawable(NativeSurface target) {
+ private GLDrawableImpl createGLPbufferDrawable(NativeSurface target) {
if (!canCreateGLPbuffer(target.getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice())) {
throw new GLException("Pbuffer support not available with current graphics card");
}
return createGLPbufferDrawableImpl(target);
}
-
+
public GLDrawable createGLPbufferDrawable(GLCapabilities capabilities,
GLCapabilitiesChooser chooser,
int width,
@@ -131,7 +139,12 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
capabilities.setDoubleBuffered(false); // FIXME DBLBUFOFFSCRN
capabilities.setOnscreen(false);
capabilities.setPBuffer(true);
- return createGLPbufferDrawable( createOffscreenSurface(capabilities, chooser, height, height) );
+ NativeWindowFactory.getDefaultToolkitLock().lock();
+ try {
+ return createGLPbufferDrawable( createOffscreenSurfaceImpl(capabilities, chooser, height, height) );
+ } finally {
+ NativeWindowFactory.getDefaultToolkitLock().unlock();
+ }
}
public GLPbuffer createGLPbuffer(GLCapabilities capabilities,
@@ -149,7 +162,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
// Offscreen GLDrawable construction
//
- protected abstract GLDrawableImpl createOffscreenDrawable(NativeSurface target) ;
+ protected abstract GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target) ;
public GLDrawable createOffscreenDrawable(GLCapabilities capabilities,
GLCapabilitiesChooser chooser,
@@ -162,16 +175,53 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
capabilities.setDoubleBuffered(false); // FIXME DBLBUFOFFSCRN
capabilities.setOnscreen(false);
capabilities.setPBuffer(false);
- return createOffscreenDrawable( createOffscreenSurface(capabilities, chooser, width, height) );
+ NativeWindowFactory.getDefaultToolkitLock().lock();
+ try {
+ return createOffscreenDrawableImpl( createOffscreenSurfaceImpl(capabilities, chooser, width, height) );
+ } finally {
+ NativeWindowFactory.getDefaultToolkitLock().unlock();
+ }
}
/**
* creates an offscreen NativeSurface, which must implement SurfaceChangeable as well,
* so the windowing system related implementation is able to set the surface handle.
*/
- protected abstract NativeSurface createOffscreenSurface(GLCapabilities capabilities, GLCapabilitiesChooser chooser,
+ protected abstract NativeSurface createOffscreenSurfaceImpl(GLCapabilities capabilities, GLCapabilitiesChooser chooser,
int width, int height);
+ //---------------------------------------------------------------------------
+ //
+ // External GLDrawable construction
+ //
+
+ protected abstract GLContext createExternalGLContextImpl();
+
+ public GLContext createExternalGLContext() {
+ NativeWindowFactory.getDefaultToolkitLock().lock();
+ try {
+ return createExternalGLContextImpl();
+ } finally {
+ NativeWindowFactory.getDefaultToolkitLock().unlock();
+ }
+ }
+
+ protected abstract GLDrawable createExternalGLDrawableImpl();
+
+ public GLDrawable createExternalGLDrawable() {
+ NativeWindowFactory.getDefaultToolkitLock().lock();
+ try {
+ return createExternalGLDrawableImpl();
+ } finally {
+ NativeWindowFactory.getDefaultToolkitLock().unlock();
+ }
+ }
+
+
+ //---------------------------------------------------------------------------
+ //
+ // GLDrawableFactoryImpl details
+ //
protected abstract GLDrawableImpl getSharedDrawable();
protected abstract GLContextImpl getSharedContext();
protected abstract void shutdown();
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java
index 19e637cab..e68ee3644 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java
@@ -67,6 +67,14 @@ public abstract class GLDrawableImpl implements GLDrawable {
/** For offscreen GLDrawables (pbuffers and "pixmap" drawables),
indicates that native resources should be reclaimed. */
public void destroy() {
+ surface.getGraphicsConfiguration().getScreen().getDevice().lock();
+ try {
+ destroyImpl();
+ } finally {
+ surface.getGraphicsConfiguration().getScreen().getDevice().unlock();
+ }
+ }
+ protected void destroyImpl() {
throw new GLException("Should not call this (should only be called for offscreen GLDrawables)");
}
@@ -129,35 +137,41 @@ public abstract class GLDrawableImpl implements GLDrawable {
return factory;
}
- public final void setRealized(boolean realized) {
- if ( this.realized != realized ) {
+ public final synchronized void setRealized(boolean realizedArg) {
+ if ( realized != realizedArg ) {
if(DEBUG) {
- System.err.println("setRealized: "+getClass().getName()+" "+this.realized+" -> "+realized);
+ System.err.println("setRealized: "+getClass().getName()+" "+realized+" -> "+realizedArg);
}
- this.realized = realized;
- if(realized && NativeSurface.LOCK_SURFACE_NOT_READY == lockSurface()) {
- throw new GLException("X11GLXDrawable.setRealized(true): lockSurface - surface not ready");
- }
- try {
- AbstractGraphicsDevice aDevice = getNativeSurface().getGraphicsConfiguration().getScreen().getDevice();
- if(!realized) {
- destroyHandle();
+ realized = realizedArg;
+ AbstractGraphicsDevice aDevice = surface.getGraphicsConfiguration().getScreen().getDevice();
+ if(realizedArg) {
+ if(NativeSurface.LOCK_SURFACE_NOT_READY >= lockSurface()) {
+ throw new GLException("X11GLXDrawable.setRealized(true): already realized, but surface not ready (lockSurface)");
}
+ } else {
+ aDevice.lock();
+ }
+ try {
setRealizedImpl();
- if(realized) {
+ if(realizedArg) {
updateHandle();
+ } else {
+ destroyHandle();
}
} finally {
- if(realized) {
+ if(realizedArg) {
unlockSurface();
+ } else {
+ aDevice.unlock();
}
}
} else if(DEBUG) {
- System.err.println("setRealized: "+getClass().getName()+" "+this.realized+" == "+realized);
+ System.err.println("setRealized: "+getClass().getName()+" "+this.realized+" == "+realizedArg);
}
}
protected abstract void setRealizedImpl();
- public boolean isRealized() {
+
+ public synchronized boolean isRealized() {
return realized;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java
index e2c217ac0..7a30f9a6f 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java
@@ -49,7 +49,7 @@ import java.beans.PropertyChangeListener;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
-import com.jogamp.common.util.RecursiveToolkitLock;
+import com.jogamp.common.util.locks.RecursiveLock;
/** Platform-independent class exposing pbuffer functionality to
applications. This class is not exposed in the public API as it
@@ -216,7 +216,7 @@ public class GLPbufferImpl implements GLPbuffer {
return pbufferDrawable.getGLProfile();
}
- private RecursiveToolkitLock recurLock = new RecursiveToolkitLock();
+ private RecursiveLock recurLock = new RecursiveLock();
public int lockSurface() throws GLException {
recurLock.lock();
@@ -231,7 +231,7 @@ public class GLPbufferImpl implements GLPbuffer {
return recurLock.isLocked();
}
- public Exception getLockedStack() {
+ public Throwable getLockedStack() {
return recurLock.getLockedStack();
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLWorkerThread.java b/src/jogl/classes/com/jogamp/opengl/impl/GLWorkerThread.java
index 768eea3f7..c292de778 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLWorkerThread.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLWorkerThread.java
@@ -254,7 +254,7 @@ public class GLWorkerThread {
Runnable curAsync = (Runnable) queue.remove(0);
curAsync.run();
} catch (Throwable t) {
- System.out.println("Exception occurred on JOGL OpenGL worker thread:");
+ System.err.println("Exception occurred on JOGL OpenGL worker thread:");
t.printStackTrace();
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/awt/AWTUtil.java b/src/jogl/classes/com/jogamp/opengl/impl/awt/AWTUtil.java
index e5570a8ee..36c0a3250 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/awt/AWTUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/awt/AWTUtil.java
@@ -117,9 +117,4 @@ public class AWTUtil {
}
}
}
-
- public static boolean isToolkitLocked() {
- return JAWTUtil.isToolkitLocked();
- }
-
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/awt/Java2D.java b/src/jogl/classes/com/jogamp/opengl/impl/awt/Java2D.java
index b871c66a7..d8f83a5f7 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/awt/Java2D.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/awt/Java2D.java
@@ -178,7 +178,7 @@ public class Java2D {
fbObjectSupportInitialized = false;
if (DEBUG && VERBOSE) {
e.printStackTrace();
- System.err.println("Disabling Java2D/JOGL FBO support");
+ System.err.println("Info: Disabling Java2D/JOGL FBO support");
}
}
@@ -192,7 +192,7 @@ public class Java2D {
} catch (Exception e) {
if (DEBUG && VERBOSE) {
e.printStackTrace();
- System.err.println("GL_ARB_texture_rectangle FBO support disabled");
+ System.err.println("Info: GL_ARB_texture_rectangle FBO support disabled");
}
}
@@ -205,7 +205,7 @@ public class Java2D {
} catch (Exception e) {
if (DEBUG && VERBOSE) {
e.printStackTrace();
- System.err.println("Unable to find class sun.java2d.opengl.CGLSurfaceData for OS X");
+ System.err.println("Info: Unable to find class sun.java2d.opengl.CGLSurfaceData for OS X");
}
}
if (cglSurfaceData != null) {
@@ -236,7 +236,7 @@ public class Java2D {
} catch (Exception e) {
if (DEBUG && VERBOSE) {
e.printStackTrace();
- System.err.println("Disabling Java2D/JOGL integration");
+ System.err.println("Info: Disabling Java2D/JOGL integration");
}
isOGLPipelineActive = false;
}
@@ -265,7 +265,7 @@ public class Java2D {
checkActive();
try {
- return ((Boolean) isQueueFlusherThreadMethod.invoke(null, new Object[] {})).booleanValue();
+ return ((Boolean) isQueueFlusherThreadMethod.invoke(null, null)).booleanValue();
} catch (InvocationTargetException e) {
throw new GLException(e.getTargetException());
} catch (Exception e) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
index b1084dd8f..83e85b922 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
@@ -115,14 +115,14 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
protected final GLDrawableImpl getSharedDrawable() { return null; }
protected final GLContextImpl getSharedContext() { return null; }
- public GLDrawableImpl createOnscreenDrawable(NativeSurface target) {
+ protected GLDrawableImpl createOnscreenDrawableImpl(NativeSurface target) {
if (target == null) {
throw new IllegalArgumentException("Null target");
}
return new EGLOnscreenDrawable(this, target);
}
- protected GLDrawableImpl createOffscreenDrawable(NativeSurface target) {
+ protected GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target) {
throw new GLException("Not yet implemented");
}
@@ -134,13 +134,13 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
return new EGLPbufferDrawable(this, target);
}
- protected NativeSurface createOffscreenSurface(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
+ protected NativeSurface createOffscreenSurfaceImpl(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
ProxySurface ns = new ProxySurface(EGLGraphicsConfigurationFactory.createOffscreenGraphicsConfiguration(capabilities, chooser));
ns.setSize(width, height);
return ns;
}
- public GLContext createExternalGLContext() {
+ protected GLContext createExternalGLContextImpl() {
AbstractGraphicsScreen absScreen = DefaultGraphicsScreen.createScreenDevice(0);
return new EGLExternalContext(absScreen);
}
@@ -149,7 +149,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
return false;
}
- public GLDrawable createExternalGLDrawable() {
+ protected GLDrawable createExternalGLDrawableImpl() {
throw new GLException("Not yet implemented");
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
index 33e301ee9..88e8a9ed1 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
@@ -53,9 +53,8 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.egl.EGLGraphicsDevice.class, this);
}
- public AbstractGraphicsConfiguration chooseGraphicsConfiguration(Capabilities capabilities,
- CapabilitiesChooser chooser,
- AbstractGraphicsScreen absScreen) {
+ protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl (
+ Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
if (absScreen == null) {
throw new IllegalArgumentException("This NativeWindowFactory accepts only AbstractGraphicsDevice objects");
}
@@ -75,7 +74,7 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
absScreen);
}
- public static EGLGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilities capabilities,
+ private static EGLGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilities capabilities,
GLCapabilitiesChooser chooser,
AbstractGraphicsScreen absScreen) {
if (capabilities == null) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
index 396d6aefc..47e0e656f 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -80,7 +80,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
try {
ReflectionUtil.createInstance("com.jogamp.opengl.impl.macosx.cgl.awt.MacOSXAWTCGLGraphicsConfigurationFactory",
- new Object[] {}, getClass().getClassLoader());
+ null, getClass().getClassLoader());
} catch (JogampRuntimeException jre) { /* n/a .. */ }
}
@@ -88,14 +88,14 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
protected final GLDrawableImpl getSharedDrawable() { return null; }
protected final GLContextImpl getSharedContext() { return null; }
- public GLDrawableImpl createOnscreenDrawable(NativeSurface target) {
+ protected GLDrawableImpl createOnscreenDrawableImpl(NativeSurface target) {
if (target == null) {
throw new IllegalArgumentException("Null target");
}
return new MacOSXOnscreenCGLDrawable(this, target);
}
- protected GLDrawableImpl createOffscreenDrawable(NativeSurface target) {
+ protected GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target) {
return new MacOSXOffscreenCGLDrawable(this, target);
}
@@ -120,14 +120,14 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
return new MacOSXPbufferCGLDrawable(this, target);
}
- protected NativeSurface createOffscreenSurface(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
+ protected NativeSurface createOffscreenSurfaceImpl(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault();
ProxySurface ns = new ProxySurface(MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capabilities, chooser, screen, true));
ns.setSize(width, height);
return ns;
}
- public GLContext createExternalGLContext() {
+ protected GLContext createExternalGLContextImpl() {
return MacOSXExternalCGLContext.create(this, null);
}
@@ -135,7 +135,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
return false;
}
- public GLDrawable createExternalGLDrawable() {
+ protected GLDrawable createExternalGLDrawableImpl() {
// FIXME
throw new GLException("Not yet implemented");
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
index ada5fb1a7..69bb245e1 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
@@ -51,9 +51,8 @@ public class MacOSXCGLGraphicsConfigurationFactory extends GraphicsConfiguration
GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.macosx.MacOSXGraphicsDevice.class, this);
}
- public AbstractGraphicsConfiguration chooseGraphicsConfiguration(Capabilities capabilities,
- CapabilitiesChooser chooser,
- AbstractGraphicsScreen absScreen) {
+ protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
+ Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
return chooseGraphicsConfigurationStatic(capabilities, chooser, absScreen, false);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
index bc470383f..14ed02918 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
@@ -77,7 +77,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
if(realized) {
createPbuffer();
} else {
- destroy();
+ destroyImpl();
}
}
@@ -85,7 +85,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
return new MacOSXPbufferCGLContext(this, shareWith);
}
- public void destroy() {
+ protected void destroyImpl() {
if (this.pBuffer != 0) {
NativeSurface ns = getNativeSurface();
impl.destroy(pBuffer);
@@ -185,7 +185,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
if (haveSetOpenGLMode) {
throw new GLException("Can't switch between using NSOpenGLPixelBuffer and CGLPBufferObj more than once");
}
- destroy();
+ destroyImpl();
openGLMode = mode;
haveSetOpenGLMode = true;
if (DEBUG) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java
index 0d59da32e..6a9617d27 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java
@@ -53,9 +53,8 @@ public class MacOSXAWTCGLGraphicsConfigurationFactory extends GraphicsConfigurat
GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.awt.AWTGraphicsDevice.class, this);
}
- public AbstractGraphicsConfiguration chooseGraphicsConfiguration(Capabilities capabilities,
- CapabilitiesChooser chooser,
- AbstractGraphicsScreen absScreen) {
+ protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
+ Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
GraphicsDevice device = null;
if (absScreen != null &&
!(absScreen instanceof AWTGraphicsScreen)) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
index 299adec50..9a86f7d08 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
@@ -89,7 +89,7 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable {
return new WindowsWGLContext(this, shareWith);
}
- public void destroy() {
+ protected void destroyImpl() {
if (hdc != 0) {
GDI.ReleaseDC(hwnd, hdc);
hdc = 0;
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
index ea02a4919..f58d2f4bc 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
@@ -48,7 +48,7 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
private long origbitmap;
private long hbitmap;
- public WindowsOffscreenWGLDrawable(GLDrawableFactory factory, NativeSurface target) {
+ protected WindowsOffscreenWGLDrawable(GLDrawableFactory factory, NativeSurface target) {
super(factory, target, true);
create();
}
@@ -57,7 +57,7 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
if(realized) {
create();
} else {
- destroy();
+ destroyImpl();
}
}
@@ -113,11 +113,10 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
hdc = 0;
throw new GLException("Error selecting bitmap into new device context");
}
-
config.updateGraphicsConfiguration(getFactory(), ns);
}
- public void destroy() {
+ protected void destroyImpl() {
NativeSurface ns = getNativeSurface();
if (ns.getSurfaceHandle() != 0) {
// Must destroy bitmap and device context
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
index 5708aa6bb..0198f334c 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
@@ -72,7 +72,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
if(realized) {
throw new GLException("Recreation via setRealized not supported.");
} else {
- destroy();
+ destroyImpl();
}
}
@@ -80,7 +80,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
return new WindowsPbufferWGLContext(this, shareWith);
}
- public void destroy() {
+ protected void destroyImpl() {
NativeSurface ns = getNativeSurface();
if(0!=buffer) {
WGLExt wglExt = cachedWGLExt;
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
index c80e46cc2..65a8e8ac3 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
@@ -298,7 +298,7 @@ public class WindowsWGLContext extends GLContextImpl {
if (!wglMakeContextCurrent(drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
throw new GLException("Error making context current: 0x" + toHexString(contextHandle) + ", werr: 0x" + Integer.toHexString(GDI.GetLastError()) + ", " + this);
} else {
- if (DEBUG && VERBOSE) {
+ if (DEBUG && (VERBOSE || newCreated)) {
System.err.println(getThreadName() + ": wglMakeCurrent(hdc " + toHexString(drawable.getHandle()) +
", contextHandle " + toHexString(contextHandle) + ") succeeded");
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
index aafea36fd..409e914b0 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -82,9 +82,10 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
new WindowsWGLGraphicsConfigurationFactory();
try {
ReflectionUtil.createInstance("com.jogamp.opengl.impl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory",
- new Object[] {}, getClass().getClassLoader());
+ null, getClass().getClassLoader());
} catch (JogampRuntimeException jre) { /* n/a .. */ }
+ NativeWindowFactory.getDefaultToolkitLock().lock(); // OK
try {
sharedDrawable = new WindowsDummyWGLDrawable(this, null);
WindowsWGLContext ctx = (WindowsWGLContext) sharedDrawable.createContext(null);
@@ -94,6 +95,8 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
sharedContext = ctx;
} catch (Throwable t) {
throw new GLException("WindowsWGLDrawableFactory - Could not initialize shared resources", t);
+ } finally {
+ NativeWindowFactory.getDefaultToolkitLock().unlock(); // OK
}
if(null==sharedContext) {
throw new GLException("WindowsWGLDrawableFactory - Shared Context is null");
@@ -135,14 +138,14 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
}
}
- public GLDrawableImpl createOnscreenDrawable(NativeSurface target) {
+ protected GLDrawableImpl createOnscreenDrawableImpl(NativeSurface target) {
if (target == null) {
throw new IllegalArgumentException("Null target");
}
return new WindowsOnscreenWGLDrawable(this, target);
}
- protected GLDrawableImpl createOffscreenDrawable(NativeSurface target) {
+ protected GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target) {
if (target == null) {
throw new IllegalArgumentException("Null target");
}
@@ -185,7 +188,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
return (GLDrawableImpl) returnList.get(0);
}
- protected NativeSurface createOffscreenSurface(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
+ protected NativeSurface createOffscreenSurfaceImpl(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault();
ProxySurface ns = new ProxySurface(WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
capabilities, chooser, screen) );
@@ -193,7 +196,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
return ns;
}
- public GLContext createExternalGLContext() {
+ protected GLContext createExternalGLContextImpl() {
return WindowsExternalWGLContext.create(this, null);
}
@@ -201,7 +204,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
return true;
}
- public GLDrawable createExternalGLDrawable() {
+ protected GLDrawable createExternalGLDrawableImpl() {
return WindowsExternalWGLDrawable.create(this, null);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index ae12d254a..c8ecb2b72 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -52,9 +52,8 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.windows.WindowsGraphicsDevice.class, this);
}
- public AbstractGraphicsConfiguration chooseGraphicsConfiguration(Capabilities capabilities,
- CapabilitiesChooser chooser,
- AbstractGraphicsScreen absScreen) {
+ protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
+ Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
GLCapabilities caps = (GLCapabilities)capabilities;
return chooseGraphicsConfigurationStatic(caps, chooser, absScreen);
}
@@ -107,10 +106,12 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
GLProfile glProfile = capabilities.getGLProfile();
long hdc = ns.getSurfaceHandle();
- if (DEBUG) {
- Exception ex = new Exception("WindowsWGLGraphicsConfigurationFactory got HDC "+toHexString(hdc));
+ if(0==hdc) {
+ throw new GLException("Error: HDC is null "+toHexString(hdc));
+ }
+ if(DEBUG) {
+ Exception ex = new Exception("Info: WindowsWGLGraphicsConfigurationFactory got HDC "+toHexString(hdc));
ex.printStackTrace();
- System.err.println("WindowsWGLGraphicsConfigurationFactory got NW "+ns);
}
PIXELFORMATDESCRIPTOR pfd = null;
@@ -120,7 +121,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
if (onscreen) {
if ((pixelFormat = GDI.GetPixelFormat(hdc)) != 0) {
- // Pixelformat already set by either
+ // Pixelformat already set by either
// - a previous updateGraphicsConfiguration() call on the same HDC,
// - the graphics driver, copying the HDC's pixelformat to the new one,
// - or the Java2D/OpenGL pipeline's configuration
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
index 02cfd14c3..26704acf3 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
@@ -53,9 +53,8 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GraphicsConfigura
GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.awt.AWTGraphicsDevice.class, this);
}
- public AbstractGraphicsConfiguration chooseGraphicsConfiguration(Capabilities capabilities,
- CapabilitiesChooser chooser,
- AbstractGraphicsScreen absScreen) {
+ protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
+ Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
GraphicsDevice device = null;
if (absScreen != null &&
!(absScreen instanceof AWTGraphicsScreen)) {
@@ -107,8 +106,7 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GraphicsConfigura
if(DEBUG) {
System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: chosen "+winConfig);
}
-
- // FIXME: we have nothing to match .. so choose the default
+
return new AWTGraphicsConfiguration(awtScreen, winConfig.getChosenCapabilities(), winConfig.getRequestedCapabilities(), gc, winConfig);
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java
index 690bc4b52..e77735637 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java
@@ -57,7 +57,7 @@ public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable {
int scrn = screen.getIndex();
long visualID = config.getVisualID();
- dummyWindow = X11Lib.CreateDummyWindow(dpy, scrn, visualID);
+ dummyWindow = X11Util.CreateDummyWindow(dpy, scrn, visualID);
ns.setSurfaceHandle( dummyWindow );
updateHandle();
@@ -74,11 +74,11 @@ public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable {
return 1;
}
- public void destroy() {
+ protected void destroyImpl() {
if(0!=dummyWindow) {
destroyHandle();
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- X11Lib.DestroyDummyWindow(config.getScreen().getDevice().getHandle(), dummyWindow);
+ X11Util.DestroyDummyWindow(config.getScreen().getDevice().getHandle(), dummyWindow);
}
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
index 494860c5b..21de61ff8 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
@@ -119,7 +119,7 @@ public abstract class X11GLXContext extends GLContextImpl {
}
} catch (RuntimeException re) {
if(DEBUG) {
- System.err.println("X11GLXContext.glXMakeContextCurrent failed: "+re+", with "+
+ System.err.println("Warning: X11GLXContext.glXMakeContextCurrent failed: "+re+", with "+
"dpy "+toHexString(dpy)+
", write "+toHexString(writeDrawable)+
", read "+toHexString(readDrawable)+
@@ -191,7 +191,7 @@ public abstract class X11GLXContext extends GLContextImpl {
ctx = glXExt.glXCreateContextAttribsARB(display, config.getFBConfig(), share, direct, attribs, 0);
} catch (RuntimeException re) {
if(DEBUG) {
- System.err.println("X11GLXContext.createContextARB glXCreateContextAttribsARB failed: "+re+", with "+getGLVersion(major, minor, ctp, "@creation"));
+ System.err.println("Warning: X11GLXContext.createContextARB glXCreateContextAttribsARB failed: "+re+", with "+getGLVersion(major, minor, ctp, "@creation"));
re.printStackTrace();
}
}
@@ -335,7 +335,7 @@ public abstract class X11GLXContext extends GLContextImpl {
if (!glXMakeContextCurrent(dpy, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
throw new GLException("Error making context current: "+this);
}
- if (DEBUG && (VERBOSE || isCreated())) {
+ if (DEBUG && (VERBOSE || newCreated)) {
System.err.println(getThreadName() + ": glXMakeCurrent(display " +
toHexString(dpy)+
", drawable " + toHexString(drawable.getHandle()) +
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index 4b84227c3..adf4d8e0d 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -53,8 +53,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
private static final DesktopGLDynamicLookupHelper x11GLXDynamicLookupHelper;
static {
- X11Util.initSingleton(); // ensure it's loaded and setup
-
DesktopGLDynamicLookupHelper tmp = null;
try {
tmp = new DesktopGLDynamicLookupHelper(new X11GLXDynamicLibraryBundleInfo());
@@ -80,35 +78,45 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
new X11GLXGraphicsConfigurationFactory();
try {
ReflectionUtil.createInstance("com.jogamp.opengl.impl.x11.glx.awt.X11AWTGLXGraphicsConfigurationFactory",
- new Object[] {}, getClass().getClassLoader());
+ null, getClass().getClassLoader());
} catch (JogampRuntimeException jre) { /* n/a .. */ }
// init shared resources ..
- long tlsDisplay = X11Util.createThreadLocalDisplay(null);
- X11GraphicsDevice sharedDevice = new X11GraphicsDevice(tlsDisplay);
- vendorName = GLXUtil.getVendorName(sharedDevice.getHandle());
- isVendorATI = GLXUtil.isVendorATI(vendorName);
- isVendorNVIDIA = GLXUtil.isVendorNVIDIA(vendorName);
- sharedScreen = new X11GraphicsScreen(sharedDevice, 0);
- sharedDrawable = new X11DummyGLXDrawable(sharedScreen, X11GLXDrawableFactory.this, GLProfile.getDefault());
- if(isVendorATI() && GLProfile.isAWTAvailable()) {
- X11Util.markThreadLocalDisplayUncloseable(tlsDisplay); // failure to close with ATI and AWT usage
- }
- if(null==sharedScreen || null==sharedDrawable) {
- throw new GLException("Couldn't init shared screen("+sharedScreen+")/drawable("+sharedDrawable+")");
- }
- // We have to keep this within this thread,
- // since we have a 'chicken-and-egg' problem otherwise on the <init> lock of this thread.
- try{
- X11GLXContext ctx = (X11GLXContext) sharedDrawable.createContext(null);
- ctx.makeCurrent();
- ctx.release();
- sharedContext = ctx;
- } catch (Throwable t) {
- throw new GLException("X11GLXDrawableFactory - Could not initialize shared resources", t);
- }
- if(null==sharedContext) {
- throw new GLException("X11GLXDrawableFactory - Shared Context is null");
+ NativeWindowFactory.getDefaultToolkitLock().lock(); // OK
+ try {
+ long tlsDisplay = X11Util.createThreadLocalDisplay(null);
+ X11Util.XLockDisplay(tlsDisplay);
+ try {
+ X11GraphicsDevice sharedDevice = new X11GraphicsDevice(tlsDisplay);
+ vendorName = GLXUtil.getVendorName(sharedDevice.getHandle());
+ isVendorATI = GLXUtil.isVendorATI(vendorName);
+ isVendorNVIDIA = GLXUtil.isVendorNVIDIA(vendorName);
+ sharedScreen = new X11GraphicsScreen(sharedDevice, 0);
+ sharedDrawable = new X11DummyGLXDrawable(sharedScreen, X11GLXDrawableFactory.this, GLProfile.getDefault());
+ if(isVendorATI() && GLProfile.isAWTAvailable()) {
+ X11Util.markThreadLocalDisplayUncloseable(tlsDisplay); // failure to close with ATI and AWT usage
+ }
+ if(null==sharedScreen || null==sharedDrawable) {
+ throw new GLException("Couldn't init shared screen("+sharedScreen+")/drawable("+sharedDrawable+")");
+ }
+ // We have to keep this within this thread,
+ // since we have a 'chicken-and-egg' problem otherwise on the <init> lock of this thread.
+ try{
+ X11GLXContext ctx = (X11GLXContext) sharedDrawable.createContext(null);
+ ctx.makeCurrent();
+ ctx.release();
+ sharedContext = ctx;
+ } catch (Throwable t) {
+ throw new GLException("X11GLXDrawableFactory - Could not initialize shared resources", t);
+ }
+ if(null==sharedContext) {
+ throw new GLException("X11GLXDrawableFactory - Shared Context is null");
+ }
+ } finally {
+ X11Util.XUnlockDisplay(tlsDisplay);
+ }
+ } finally {
+ NativeWindowFactory.getDefaultToolkitLock().unlock(); // OK
}
if (DEBUG) {
System.err.println("!!! Vendor: "+vendorName+", ATI: "+isVendorATI+", NV: "+isVendorNVIDIA);
@@ -122,9 +130,9 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
private boolean isVendorATI;
private boolean isVendorNVIDIA;
- public String getVendorName() { return vendorName; }
- public boolean isVendorATI() { return isVendorATI; }
- public boolean isVendorNVIDIA() { return isVendorNVIDIA; }
+ protected String getVendorName() { return vendorName; }
+ protected boolean isVendorATI() { return isVendorATI; }
+ protected boolean isVendorNVIDIA() { return isVendorNVIDIA; }
private X11DummyGLXDrawable sharedDrawable=null;
private X11GLXContext sharedContext=null;
@@ -165,14 +173,14 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
X11Util.shutdown( false, DEBUG );
}
- public GLDrawableImpl createOnscreenDrawable(NativeSurface target) {
+ protected GLDrawableImpl createOnscreenDrawableImpl(NativeSurface target) {
if (target == null) {
throw new IllegalArgumentException("Null target");
}
return new X11OnscreenGLXDrawable(this, target);
}
- protected GLDrawableImpl createOffscreenDrawable(NativeSurface target) {
+ protected GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target) {
if (target == null) {
throw new IllegalArgumentException("Null target");
}
@@ -185,7 +193,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
private boolean glxVersionsQueried = false;
private int glxVersionMajor=0, glxVersionMinor=0;
- public boolean glxVersionGreaterEqualThan(AbstractGraphicsDevice device, int majorReq, int minorReq) {
+ protected final boolean glxVersionGreaterEqualThan(AbstractGraphicsDevice device, int majorReq, int minorReq) {
if (!glxVersionsQueried) {
if(null == device) {
device = (X11GraphicsDevice) sharedScreen.getDevice();
@@ -193,19 +201,24 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
if(null == device) {
throw new GLException("FIXME: No AbstractGraphicsDevice (passed or shared-device");
}
- long display = device.getHandle();
- int[] major = new int[1];
- int[] minor = new int[1];
-
- GLXUtil.getGLXVersion(display, major, minor);
- if (DEBUG) {
- System.err.println("!!! GLX version: major " + major[0] +
- ", minor " + minor[0]);
- }
+ device.lock(); // OK
+ try {
+ long display = device.getHandle();
+ int[] major = new int[1];
+ int[] minor = new int[1];
+
+ GLXUtil.getGLXVersion(display, major, minor);
+ if (DEBUG) {
+ System.err.println("!!! GLX version: major " + major[0] +
+ ", minor " + minor[0]);
+ }
- glxVersionMajor = major[0];
- glxVersionMinor = minor[0];
- glxVersionsQueried = true;
+ glxVersionMajor = major[0];
+ glxVersionMinor = minor[0];
+ glxVersionsQueried = true;
+ } finally {
+ device.unlock(); // OK
+ }
}
return ( glxVersionMajor > majorReq ) || ( glxVersionMajor == majorReq && glxVersionMinor >= minorReq ) ;
}
@@ -239,7 +252,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
}
- protected NativeSurface createOffscreenSurface(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
+ protected NativeSurface createOffscreenSurfaceImpl(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
ProxySurface ns = new ProxySurface(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capabilities, chooser, sharedScreen));
if(ns != null) {
ns.setSize(width, height);
@@ -247,7 +260,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
return ns;
}
- public GLContext createExternalGLContext() {
+ protected GLContext createExternalGLContextImpl() {
return X11ExternalGLXContext.create(this, null);
}
@@ -255,7 +268,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
return canCreateGLPbuffer(device);
}
- public GLDrawable createExternalGLDrawable() {
+ protected GLDrawable createExternalGLDrawableImpl() {
return X11ExternalGLXDrawable.create(this, null);
}
@@ -282,9 +295,9 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
long display = sharedScreen.getDevice().getHandle();
int[] size = new int[1];
- boolean res = X11Lib.XF86VidModeGetGammaRampSize(display,
- X11Lib.DefaultScreen(display),
- size, 0);
+ boolean res = X11Util.XF86VidModeGetGammaRampSize(display,
+ X11Util.DefaultScreen(display),
+ size, 0);
if (!res) {
return 0;
}
@@ -301,8 +314,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
}
long display = sharedScreen.getDevice().getHandle();
- boolean res = X11Lib.XF86VidModeSetGammaRamp(display,
- X11Lib.DefaultScreen(display),
+ boolean res = X11Util.XF86VidModeSetGammaRamp(display,
+ X11Util.DefaultScreen(display),
rampData.length,
rampData, 0,
rampData, 0,
@@ -323,8 +336,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
rampData.limit(3 * size);
ShortBuffer blueRampData = rampData.slice();
long display = sharedScreen.getDevice().getHandle();
- boolean res = X11Lib.XF86VidModeGetGammaRamp(display,
- X11Lib.DefaultScreen(display),
+ boolean res = X11Util.XF86VidModeGetGammaRamp(display,
+ X11Util.DefaultScreen(display),
size,
redRampData,
greenRampData,
@@ -354,8 +367,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
rampData.limit(3 * size);
ShortBuffer blueRampData = rampData.slice();
long display = sharedScreen.getDevice().getHandle();
- X11Lib.XF86VidModeSetGammaRamp(display,
- X11Lib.DefaultScreen(display),
+ X11Util.XF86VidModeSetGammaRamp(display,
+ X11Util.DefaultScreen(display),
size,
redRampData,
greenRampData,
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
index 589d7b2db..3df9ee541 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
@@ -339,7 +339,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
int[] count = new int[1];
XVisualInfo template = XVisualInfo.create();
template.setVisualid(visualID);
- XVisualInfo[] infos = X11Lib.XGetVisualInfo(display, X11Lib.VisualIDMask, template, count, 0);
+ XVisualInfo[] infos = X11Util.XGetVisualInfo(display, X11Lib.VisualIDMask, template, count, 0);
if (infos == null || infos.length == 0) {
return null;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
index 9884db288..8dbd69dce 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
@@ -53,9 +53,8 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.x11.X11GraphicsDevice.class, this);
}
- public AbstractGraphicsConfiguration chooseGraphicsConfiguration(Capabilities capabilities,
- CapabilitiesChooser chooser,
- AbstractGraphicsScreen absScreen) {
+ protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
+ Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
if (!(absScreen instanceof X11GraphicsScreen)) {
throw new IllegalArgumentException("Only X11GraphicsScreen are allowed here");
}
@@ -95,7 +94,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
int screen = x11Screen.getIndex();
boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
- long visID = X11Lib.DefaultVisualID(display, x11Screen.getIndex());
+ long visID = X11Util.DefaultVisualID(display, x11Screen.getIndex());
xvis = X11GLXGraphicsConfiguration.XVisualID2XVisualInfo(display, visID);
caps = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(glProfile, display, xvis, onscreen, usePBuffer, isMultisampleAvailable);
@@ -140,7 +139,8 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
caps2.setDoubleBuffered(false);
}
- X11GLXGraphicsConfiguration res = chooseGraphicsConfigurationFBConfig(caps2, chooser, x11Screen);
+ X11GLXGraphicsConfiguration res;
+ res = chooseGraphicsConfigurationFBConfig(caps2, chooser, x11Screen);
if(null==res) {
if(usePBuffer) {
throw new GLException("Error: Couldn't create X11GLXGraphicsConfiguration based on FBConfig for "+caps2);
@@ -156,7 +156,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
return res;
}
- protected static X11GLXGraphicsConfiguration chooseGraphicsConfigurationFBConfig(GLCapabilities capabilities,
+ private static X11GLXGraphicsConfiguration chooseGraphicsConfigurationFBConfig(GLCapabilities capabilities,
GLCapabilitiesChooser chooser,
X11GraphicsScreen x11Screen) {
long recommendedFBConfig = 0;
@@ -277,7 +277,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
return new X11GLXGraphicsConfiguration(x11Screen, caps[chosen], capabilities, chooser, retXVisualInfo, fbcfgsL.get(chosen), retFBID);
}
- protected static X11GLXGraphicsConfiguration chooseGraphicsConfigurationXVisual(GLCapabilities capabilities,
+ private static X11GLXGraphicsConfiguration chooseGraphicsConfigurationXVisual(GLCapabilities capabilities,
GLCapabilitiesChooser chooser,
X11GraphicsScreen x11Screen) {
if (chooser == null) {
@@ -315,7 +315,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
int[] count = new int[1];
XVisualInfo template = XVisualInfo.create();
template.setScreen(screen);
- infos = X11Lib.XGetVisualInfo(display, X11Lib.VisualScreenMask, template, count, 0);
+ infos = X11Util.XGetVisualInfo(display, X11Lib.VisualScreenMask, template, count, 0);
if (infos == null || infos.length<1) {
throw new GLException("Error while enumerating available XVisualInfos");
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
index 3be34eb6a..f46bdbb75 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
@@ -56,7 +56,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
if(realized) {
create();
} else {
- destroy();
+ destroyImpl();
}
}
@@ -74,14 +74,14 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
long dpy = aDevice.getHandle();
int screen = aScreen.getIndex();
- pixmap = X11Lib.XCreatePixmap(dpy, X11Lib.RootWindow(dpy, screen),
+ pixmap = X11Util.XCreatePixmap(dpy, X11Util.RootWindow(dpy, screen),
surface.getWidth(), surface.getHeight(), bitsPerPixel);
if (pixmap == 0) {
throw new GLException("XCreatePixmap failed");
}
long drawable = GLX.glXCreateGLXPixmap(dpy, vis, pixmap);
if (drawable == 0) {
- X11Lib.XFreePixmap(dpy, pixmap);
+ X11Util.XFreePixmap(dpy, pixmap);
pixmap = 0;
throw new GLException("glXCreateGLXPixmap failed");
}
@@ -93,7 +93,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
}
}
- public void destroy() {
+ protected void destroyImpl() {
if (pixmap == 0) return;
NativeSurface ns = getNativeSurface();
@@ -122,7 +122,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
GLX.glXMakeCurrent(display, 0, 0);
GLX.glXDestroyGLXPixmap(display, drawable);
- X11Lib.XFreePixmap(display, pixmap);
+ X11Util.XFreePixmap(display, pixmap);
drawable = 0;
pixmap = 0;
((SurfaceChangeable)ns).setSurfaceHandle(0);
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
index ce9e6d75d..b86394cc6 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
@@ -65,7 +65,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
if(realized) {
createPbuffer();
} else {
- destroy();
+ destroyImpl();
}
}
@@ -73,7 +73,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
return new X11PbufferGLXContext(this, shareWith);
}
- public void destroy() {
+ protected void destroyImpl() {
NativeSurface ns = getNativeSurface();
if (ns.getSurfaceHandle() != 0) {
GLX.glXDestroyPbuffer(ns.getDisplayHandle(), ns.getSurfaceHandle());
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
index de55a3148..99791b43e 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
@@ -32,6 +32,7 @@
package com.jogamp.opengl.impl.x11.glx.awt;
+import com.jogamp.nativewindow.impl.jawt.JAWTUtil;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import javax.media.nativewindow.*;
@@ -50,9 +51,8 @@ public class X11AWTGLXGraphicsConfigurationFactory extends GraphicsConfiguration
GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.awt.AWTGraphicsDevice.class, this);
}
- public AbstractGraphicsConfiguration chooseGraphicsConfiguration(Capabilities capabilities,
- CapabilitiesChooser chooser,
- AbstractGraphicsScreen absScreen) {
+ protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
+ Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
GraphicsDevice device = null;
if (absScreen != null &&
!(absScreen instanceof AWTGraphicsScreen)) {
@@ -93,7 +93,7 @@ public class X11AWTGLXGraphicsConfigurationFactory extends GraphicsConfiguration
System.err.println("X11AWTGLXGraphicsConfigurationFactory: using AWT X11 display 0x"+Long.toHexString(displayHandle));
}
}
- ((AWTGraphicsDevice)awtScreen.getDevice()).setHandle(displayHandle);
+ ((AWTGraphicsDevice)awtScreen.getDevice()).setSubType(NativeWindowFactory.TYPE_X11, displayHandle);
X11GraphicsDevice x11Device = new X11GraphicsDevice(displayHandle);
X11GraphicsScreen x11Screen = new X11GraphicsScreen(x11Device, awtScreen.getIndex());
diff --git a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java
index 04b994198..d9fce6e6a 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java
@@ -85,7 +85,7 @@ public class ImmModeSink {
public void draw(GL gl, boolean disableBufferAfterDraw) {
if(DEBUG_DRAW) {
- Exception e = new Exception("ImmModeSink.draw(disableBufferAfterDraw: "+disableBufferAfterDraw+"):\n\t"+this);
+ Exception e = new Exception("Info: ImmModeSink.draw(disableBufferAfterDraw: "+disableBufferAfterDraw+"):\n\t"+this);
e.printStackTrace();
}
int n=0;
@@ -96,7 +96,7 @@ public class ImmModeSink {
public void draw(GL gl, Buffer indices, boolean disableBufferAfterDraw) {
if(DEBUG_DRAW) {
- Exception e = new Exception("ImmModeSink.draw(disableBufferAfterDraw: "+disableBufferAfterDraw+"):\n\t"+this);
+ Exception e = new Exception("Info: ImmModeSink.draw(disableBufferAfterDraw: "+disableBufferAfterDraw+"):\n\t"+this);
e.printStackTrace();
}
int n=0;
@@ -107,7 +107,7 @@ public class ImmModeSink {
public void glBegin(int mode) {
if(DEBUG_BEGIN_END) {
- Exception e = new Exception("ImmModeSink.glBegin("+vboSet.mode+"):\n\t"+this);
+ Exception e = new Exception("Info: ImmModeSink.glBegin("+vboSet.mode+"):\n\t"+this);
e.printStackTrace();
}
vboSet.modeOrig = mode;
@@ -141,7 +141,7 @@ public class ImmModeSink {
private void glEnd(GL gl, Buffer indices, boolean immediateDraw) {
if(DEBUG_BEGIN_END) {
- Exception e = new Exception("ImmModeSink START glEnd(immediate: "+immediateDraw+"):\n\t"+this);
+ Exception e = new Exception("Info: ImmModeSink START glEnd(immediate: "+immediateDraw+"):\n\t"+this);
e.printStackTrace();
}
if(immediateDraw) {
@@ -328,7 +328,7 @@ public class ImmModeSink {
protected void draw(GL gl, Buffer indices, boolean disableBufferAfterDraw, int i)
{
if(DEBUG_DRAW) {
- Exception e = new Exception("ImmModeSink.draw["+i+"](disableBufferAfterDraw: "+disableBufferAfterDraw+"):\n\t"+this);
+ Exception e = new Exception("Info: ImmModeSink.draw["+i+"](disableBufferAfterDraw: "+disableBufferAfterDraw+"):\n\t"+this);
e.printStackTrace();
}
enableBuffer(gl, true);
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index a85993c8e..f9f5f8324 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -127,7 +127,7 @@ public abstract class GLDrawableFactory {
tmp = (GLDrawableFactory) ReflectionUtil.createInstance(factoryClassName, cl);
} catch (JogampRuntimeException jre) {
if (GLProfile.DEBUG) {
- System.err.println("GLDrawableFactory.static - Native Platform: "+nativeOSType+" - not available: "+factoryClassName);
+ System.err.println("Info: GLDrawableFactory.static - Native Platform: "+nativeOSType+" - not available: "+factoryClassName);
jre.printStackTrace();
}
}
@@ -139,7 +139,7 @@ public abstract class GLDrawableFactory {
tmp = (GLDrawableFactory) ReflectionUtil.createInstance("com.jogamp.opengl.impl.egl.EGLDrawableFactory", cl);
} catch (JogampRuntimeException jre) {
if (GLProfile.DEBUG) {
- System.err.println("GLDrawableFactory.static - EGLDrawableFactory - not available");
+ System.err.println("Info: GLDrawableFactory.static - EGLDrawableFactory - not available");
jre.printStackTrace();
}
}
diff --git a/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java b/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java
index 352545849..590e88ab7 100644
--- a/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java
@@ -152,11 +152,11 @@ public class GLPipelineFactory {
instance = cstr.newInstance( cstrArgs ) ;
} catch (Throwable t) { t.printStackTrace(); }
if(null==instance) {
- throw new GLException("Couldn't create instance of pipeline: "+upstreamClazz.getName()+
+ throw new GLException("Error: Couldn't create instance of pipeline: "+upstreamClazz.getName()+
" ( "+getArgsClassNameList(downstreamClazz, additionalArgs) +" )");
}
if( ! (instance instanceof GL) ) {
- throw new GLException(upstreamClazz.getName()+" not an instance of GL");
+ throw new GLException("Error: "+upstreamClazz.getName()+" not an instance of GL");
}
return (GL) instance;
}
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 287e7a5a9..be5968409 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -37,7 +37,9 @@
package javax.media.opengl;
+import com.jogamp.common.jvm.JVMUtil;
import com.jogamp.common.util.ReflectionUtil;
+import com.jogamp.opengl.util.VersionInfo;
import com.jogamp.opengl.impl.Debug;
import com.jogamp.opengl.impl.GLDrawableFactoryImpl;
import com.jogamp.opengl.impl.GLDynamicLookupHelper;
@@ -281,6 +283,7 @@ public class GLProfile {
* @see #GL_PROFILE_LIST_ALL
*/
public static final GLProfile getDefault() {
+ validateInitialization();
if(null==defaultGLProfile) {
throw new GLException("No default profile available"); // should never be reached
}
@@ -349,6 +352,7 @@ public class GLProfile {
public static final GLProfile get(String profile)
throws GLException
{
+ validateInitialization();
if(null==profile || profile.equals("GL")) return getDefault();
GLProfile glProfile = (GLProfile) mappedProfiles.get(profile);
if(null==glProfile) {
@@ -366,6 +370,7 @@ public class GLProfile {
public static final GLProfile get(String[] profiles)
throws GLException
{
+ validateInitialization();
for(int i=0; i<profiles.length; i++) {
String profile = profiles[i];
GLProfile glProfile = (GLProfile) mappedProfiles.get(profile);
@@ -851,9 +856,9 @@ public class GLProfile {
* Tries the profiles implementation and native libraries.
* Throws an GLException if no profile could be found at all.
*/
- private static void initProfiles() {
+ private static void initProfiles(boolean firstUIActionOnProcess) {
- NativeWindowFactory.initSingleton();
+ NativeWindowFactory.initSingleton(firstUIActionOnProcess);
ClassLoader classloader = GLProfile.class.getClassLoader();
@@ -898,13 +903,15 @@ public class GLProfile {
t=le;
} catch (RuntimeException re) {
t=re;
+ } catch (Throwable tt) {
+ t=tt;
}
if(DEBUG) {
if(null!=t) {
t.printStackTrace();
}
if(!hasNativeOSFactory) {
- System.err.println("GLProfile.static - Native platform GLDrawable factory not available");
+ System.err.println("Info: GLProfile.init - Native platform GLDrawable factory not available");
}
}
@@ -969,41 +976,80 @@ public class GLProfile {
mappedProfiles = computeProfileMap();
if (DEBUG) {
- System.err.println("GLProfile.static isAWTAvailable "+isAWTAvailable);
- System.err.println("GLProfile.static hasNativeOSFactory "+hasNativeOSFactory);
- System.err.println("GLProfile.static hasDesktopGL "+hasDesktopGL);
- System.err.println("GLProfile.static hasDesktopGLES12 "+hasDesktopGLES12);
- System.err.println("GLProfile.static hasGL234Impl "+hasGL234Impl);
- System.err.println("GLProfile.static "+glAvailabilityToString());
+ System.err.println(VersionInfo.getPackageInfo(null, "GLProfile.init", "javax.media.opengl", "GL"));
+ System.err.println(VersionInfo.getPlatformInfo(null, "GLProfile.init"));
+ System.err.println("GLProfile.init firstUIActionOnProcess "+firstUIActionOnProcess);
+ System.err.println("GLProfile.init isAWTAvailable "+isAWTAvailable);
+ System.err.println("GLProfile.init hasNativeOSFactory "+hasNativeOSFactory);
+ System.err.println("GLProfile.init hasDesktopGL "+hasDesktopGL);
+ System.err.println("GLProfile.init hasDesktopGLES12 "+hasDesktopGLES12);
+ System.err.println("GLProfile.init hasGL234Impl "+hasGL234Impl);
+ System.err.println("GLProfile.init "+glAvailabilityToString());
}
+ }
+ static {
+ JVMUtil.initSingleton();
}
+ static boolean initialized = false;
+
/**
- * Initializes available profiles eagerly.
+ * Static one time initialization of JOGL.
+ * <p>
+ * Applications shall call this methods <b>ASAP</b>, before any other UI invocation.<br>
+ * You may issue the call in your main function.<br>
+ * In case applications are able to initialize JOGL before any other UI action,<br>
+ * they shall invoke this method with <code>firstUIActionOnProcess=true</code> and benefit from fast native multithreading support on all platforms if possible.</P>
+ * <P>
+ * RCP Application (Applet's, Webstart, Netbeans, ..) using JOGL may not be able to initialize JOGL
+ * before the first UI action.<br>
+ * In such case you shall invoke this method with <code>firstUIActionOnProcess=false</code>.<br>
+ * On some platforms, notably X11 with AWT usage, JOGL will utilize special locking mechanisms which may slow down your
+ * application.</P>
+ * <P>
+ * Remark: NEWT is currently not affected by this behavior, ie always uses native multithreading.</P>
+ * <P>
+ * However, in case this method is not invoked, hence GLProfile is not initialized explicitly by the user,<br>
+ * the first call to {@link #getDefault()}, {@link #get(java.lang.String)}, etc, will initialize with <code>firstUIActionOnProcess=false</code>,<br>
+ * hence without the possibility to enable native multithreading.<br>
+ * This is not the recommended way, since it may has a performance impact, but it allows you to run code without explicit initialization.</P>
+ * <P>
+ * In case no explicit initialization was invoked and the implicit initialization didn't happen,<br>
+ * you may encounter the following exception:
+ * <pre>
+ * javax.media.opengl.GLException: No default profile available
+ * </pre></P>
+ *
+ * @param firstUIActionOnProcess Should be <code>true</code> if called before the first UI action of the running program,
+ * otherwise <code>false</code>.
*/
- static {
- // run the whole static initialization privileged to speed up,
- // since this skips checking further access
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- initProfiles();
- return null;
- }
- });
+ public static synchronized void initSingleton(final boolean firstUIActionOnProcess) {
+ if(!initialized) {
+ initialized = true;
+ // run the whole static initialization privileged to speed up,
+ // since this skips checking further access
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ initProfiles(firstUIActionOnProcess);
+ return null;
+ }
+ });
- if(null==defaultGLProfile) {
- throw new GLException("No profile available: "+array2String(GL_PROFILE_LIST_ALL)+", "+glAvailabilityToString());
+ if(null==defaultGLProfile) {
+ throw new GLException("No profile available: "+array2String(GL_PROFILE_LIST_ALL)+", "+glAvailabilityToString());
+ }
}
}
- /**
- * It is mandatory to call this methods ASAP, before anything else.<br>
- * You may issue the call in your main class static initializer block, or in the static main function.<br>
- * This will kick off JOGL's static initialization.<br>
- * It is essential to do this at the very beginning, so JOGL has a chance to initialize multithreading support.<br>
- */
- public static void initSingleton() {
+ private static void validateInitialization() {
+ if(!initialized) {
+ synchronized(GLProfile.class) {
+ if(!initialized) {
+ initSingleton(false);
+ }
+ }
+ }
}
private static final String array2String(String[] list) {
@@ -1028,17 +1074,17 @@ public class GLProfile {
GLProfile glProfile = new GLProfile(profile, profileImpl);
_mappedProfiles.put(profile, glProfile);
if (DEBUG) {
- System.err.println("GLProfile.static map "+glProfile);
+ System.err.println("GLProfile.init map "+glProfile);
}
if(null==defaultGLProfile) {
defaultGLProfile=glProfile;
if (DEBUG) {
- System.err.println("GLProfile.static default "+glProfile);
+ System.err.println("GLProfile.init default "+glProfile);
}
}
} else {
if (DEBUG) {
- System.err.println("GLProfile.static map *** no mapping for "+profile);
+ System.err.println("GLProfile.init map *** no mapping for "+profile);
}
}
}
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 60ed731f1..4ac21204f 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -45,7 +45,6 @@ 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;
@@ -54,7 +53,6 @@ import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
-import java.awt.Container;
import java.awt.Window;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;
@@ -79,9 +77,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
private static final GLProfile defaultGLProfile;
static {
- NativeWindowFactory.initSingleton();
- defaultGLProfile = GLProfile.getDefault();
DEBUG = Debug.debug("GLCanvas");
+ defaultGLProfile = GLProfile.getDefault();
}
private GLProfile glProfile;
@@ -234,7 +231,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
final GraphicsConfiguration compatible = (null!=config)?config.getGraphicsConfiguration():null;
boolean equalCaps = config.getChosenCapabilities().equals(awtConfig.getChosenCapabilities());
if(DEBUG) {
- Exception e = new Exception("Call Stack: "+Thread.currentThread().getName());
+ Exception e = new Exception("Info: Call Stack: "+Thread.currentThread().getName());
e.printStackTrace();
System.err.println("!!! Created Config (n): HAVE GC "+chosen);
System.err.println("!!! Created Config (n): THIS GC "+gc);
@@ -313,7 +310,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
protected void dispose(boolean regenerate) {
if(DEBUG) {
- Exception ex1 = new Exception("dispose("+regenerate+") - start");
+ Exception ex1 = new Exception("Info: dispose("+regenerate+") - start");
ex1.printStackTrace();
}
@@ -381,7 +378,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
(int) ((getHeight() + bounds.getHeight()) / 2));
return;
}
- if( this.drawableHelper.isExternalAnimatorAnimating() ) {
+ if( ! this.drawableHelper.isExternalAnimatorAnimating() ) {
display();
}
}
@@ -408,11 +405,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
/*
* Save the chosen capabilities for use in getGraphicsConfiguration().
*/
- JAWTUtil.lockToolkit();
+ NativeWindowFactory.getDefaultToolkitLock().lock();
try {
awtConfig = chooseGraphicsConfiguration(capabilities, chooser, device);
if(DEBUG) {
- Exception e = new Exception("Created Config: "+awtConfig);
+ Exception e = new Exception("Info: Created Config: "+awtConfig);
e.printStackTrace();
}
if(null!=awtConfig) {
@@ -427,7 +424,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
context = (GLContextImpl) drawable.createContext(shareWith);
context.setSynchronized(true);
} finally {
- JAWTUtil.unlockToolkit();
+ NativeWindowFactory.getDefaultToolkitLock().unlock();
}
if(DEBUG) {
@@ -446,7 +443,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
<DL><DD><CODE>removeNotify</CODE> in class <CODE>java.awt.Component</CODE></DD></DL> */
public void removeNotify() {
if(DEBUG) {
- Exception ex1 = new Exception("removeNotify - start");
+ Exception ex1 = new Exception("Info: removeNotify - start");
ex1.printStackTrace();
}
@@ -461,7 +458,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
}
}
if(DEBUG) {
- System.out.println("removeNotify - end");
+ System.err.println("Info: removeNotify - end");
}
}
@@ -580,7 +577,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
}
public String toString() {
- return "AWT-GLCanvas[ "+awtConfig+", "+((null!=drawable)?drawable.getClass().getName():"null-drawable")+", "+drawableHelper+"]";
+ return "AWT-GLCanvas[ "+awtConfig+", "+((null!=drawable)?drawable.getClass().getName():"null-drawable")+"]";
}
//----------------------------------------------------------------------
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index e4a295ba3..192695955 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -138,8 +138,6 @@ 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
@@ -212,7 +210,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
protected void dispose(boolean regenerate) {
if(DEBUG) {
- Exception ex1 = new Exception("dispose("+regenerate+") - start");
+ Exception ex1 = new Exception("Info: dispose("+regenerate+") - start");
ex1.printStackTrace();
}
if (backend != null) {
@@ -287,10 +285,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return;
}
- if ( drawableHelper.isExternalAnimatorAnimating() ) {
- return;
- }
-
if (backend == null || !isInitialized) {
createAndInitializeBackend();
}
@@ -334,7 +328,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
<DL><DD><CODE>removeNotify</CODE> in class <CODE>java.awt.Component</CODE></DD></DL> */
public void removeNotify() {
if(DEBUG) {
- Exception ex1 = new Exception("removeNotify - start");
+ Exception ex1 = new Exception("Info: removeNotify - start");
ex1.printStackTrace();
}
dispose(false);
@@ -345,7 +339,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
isInitialized = false;
super.removeNotify();
if(DEBUG) {
- System.out.println("removeNotify - end");
+ System.err.println("Info: removeNotify - end");
}
}
@@ -617,7 +611,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
}
public String toString() {
- return "AWT-GLJPanel[ "+((null!=backend)?backend.getDrawable().getClass().getName():"null-drawable")+", "+drawableHelper+"]";
+ return "AWT-GLJPanel[ "+((null!=backend)?backend.getDrawable().getClass().getName():"null-drawable")+"]";
}
private boolean disposeRegenerate;
@@ -1034,7 +1028,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
} catch (GLException e) {
if (DEBUG) {
e.printStackTrace();
- System.err.println("GLJPanel: Falling back on software rendering because of problems creating pbuffer");
+ System.err.println("Info: GLJPanel: Falling back on software rendering because of problems creating pbuffer");
}
hardwareAccelerationDisabled = true;
backend = null;
@@ -1111,7 +1105,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
readBackWidthInPixels = Math.max(1, panelWidth);
readBackHeightInPixels = Math.max(1, panelHeight);
if (DEBUG) {
- System.err.println("WARNING: falling back to software rendering due to bugs in OpenGL drivers");
+ System.err.println("Warning: falling back to software rendering due to bugs in OpenGL drivers");
e.printStackTrace();
}
createAndInitializeBackend();