aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-04-13 21:24:44 +0200
committerSven Gothel <[email protected]>2010-04-13 21:24:44 +0200
commit2df3bea10859ee2f2c4b3622f3b610b17a5749d6 (patch)
tree9bb948241aef06fdaf1dd4d09f1b31989c76f858 /src/jogl/classes/com
parent1c1053c6a8b669c067ae1316b9770871e213ea05 (diff)
ATI (fglrx) PBuffer/X11Display bug workaround/cleanup
- See https://bugzilla.mozilla.org/show_bug.cgi?id=486277 - Description: - To use PBuffer, a context must be current - X11Display cannot be switched while using the PBuffer [within one thread]. Hence we shall try harder to reuse _the_ user configured X11Display - whenever possible. This is actually a good thing, ie cleanup up our code again. - Changes to workaround/cleanup: - GLDrawableFactory* methods 'canCreate*()' are changed to 'canCreate*(AbstractGraphicsDevice)' to allow pipelining the X11Display. This reduces the overhead of using a local TLS X11Display. - WindowsDummyWGLDrawable cstr gets the GLProfile as a parameter now, this is done while adding X11DummyGLXDrawable - forseeing the usecase to query available GLProfiles at startup. - X11DummyGLXDrawable added, following the WindowsDummyWGLDrawable path to have a dummy GLContext current to fix the ATI bug. NativeWindow X11: - Add XIOErrorHandler to identify the fatal failure of closing a Display (-> ATI bug). Build: - Adding ant.jar and ant-junit.jar to the junit compile/run classpath - Misc: - Fix: CreateDummyWindow(..) returns a HWND, not a HDC - mapToRealGLFunctionName: Added mapping for X11/GLX. - X11GLXGraphicsConfigurationFactory: Uncommented dead code 'createDefaultGraphicsConfigurationFBConfig' Tests: Passed (Linux64bit: NVidia/ATI) Todo: More tests on ATI, especially multithreading/X11Display usage.
Diffstat (limited to 'src/jogl/classes/com')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java26
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java13
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java8
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java8
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java6
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java14
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java6
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLDrawableFactory.java3
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java7
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java18
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java20
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java15
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java85
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java22
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java88
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java5
16 files changed, 229 insertions, 115 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
index 893827a8c..7543a1084 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
@@ -41,6 +41,7 @@ package com.jogamp.opengl.impl;
import com.jogamp.common.os.DynamicLookupHelper;
import java.nio.*;
+import java.util.*;
import javax.media.opengl.*;
import com.jogamp.nativewindow.impl.NWReflection;
@@ -346,13 +347,30 @@ public abstract class GLContextImpl extends GLContext {
/** Maps the given "platform-independent" function name to a real function
name. Currently this is only used to map "glAllocateMemoryNV" and
associated routines to wglAllocateMemoryNV / glXAllocateMemoryNV. */
- protected abstract String mapToRealGLFunctionName(String glFunctionName);
+ protected String mapToRealGLFunctionName(String glFunctionName) {
+ Map/*<String, String>*/ map = getFunctionNameMap();
+ String lookup = ( null != map ) ? (String) map.get(glFunctionName) : null;
+ if (lookup != null) {
+ return lookup;
+ }
+ return glFunctionName;
+ }
+ protected abstract Map/*<String, String>*/ getFunctionNameMap() ;
/** Maps the given "platform-independent" extension name to a real
function name. Currently this is only used to map
- "GL_ARB_pbuffer" and "GL_ARB_pixel_format" to "WGL_ARB_pbuffer"
- and "WGL_ARB_pixel_format" (not yet mapped to X11). */
- protected abstract String mapToRealGLExtensionName(String glExtensionName);
+ "GL_ARB_pbuffer" to "WGL_ARB_pbuffer/GLX_SGIX_pbuffer" and
+ "GL_ARB_pixel_format" to "WGL_ARB_pixel_format/n.a."
+ */
+ protected String mapToRealGLExtensionName(String glExtensionName) {
+ Map/*<String, String>*/ map = getExtensionNameMap();
+ String lookup = ( null != map ) ? (String) map.get(glExtensionName) : null;
+ if (lookup != null) {
+ return lookup;
+ }
+ return glExtensionName;
+ }
+ protected abstract Map/*<String, String>*/ getExtensionNameMap() ;
/** Helper routine which resets a ProcAddressTable generated by the
GLEmitter by looking up anew all of its function pointers. */
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
index c8faf0f65..35810678c 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
@@ -54,6 +54,9 @@ import java.lang.reflect.*;
public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
protected static final boolean DEBUG = Debug.debug("GLDrawableFactory");
+ public void shutdown() {
+ }
+
//---------------------------------------------------------------------------
// Dispatching GLDrawable construction in respect to the NativeWindow Capabilities
//
@@ -76,7 +79,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
if( ! ( target instanceof SurfaceChangeable ) ) {
throw new IllegalArgumentException("Passed NativeWindow must implement SurfaceChangeable for offscreen: "+target);
}
- if(caps.isPBuffer() && canCreateGLPbuffer()) {
+ if(caps.isPBuffer()) {
if(DEBUG) {
System.out.println("GLDrawableFactoryImpl.createGLDrawable -> PbufferDrawable: "+target);
}
@@ -111,7 +114,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
protected abstract GLDrawableImpl createGLPbufferDrawableImpl(NativeWindow target);
protected GLDrawableImpl createGLPbufferDrawable(NativeWindow target) {
- if (!canCreateGLPbuffer()) {
+ if (!canCreateGLPbuffer(target.getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice())) {
throw new GLException("Pbuffer support not available with current graphics card");
}
return createGLPbufferDrawableImpl(target);
@@ -215,7 +218,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
// implement this functionality on all other platforms
//
- public abstract boolean canCreateContextOnJava2DSurface();
+ public abstract boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device);
public abstract GLContext createContextOnJava2DSurface(Object graphics, GLContext shareWith)
throws GLException;
@@ -312,7 +315,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
throw new IllegalArgumentException("Should not call this unless setDisplayGamma called first");
}
resetGammaRamp(originalGammaRamp);
- unregisterGammeShutdownHook();
+ unregisterGammaShutdownHook();
}
//------------------------------------------------------
@@ -364,7 +367,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
gammaShutdownHookRegistered = true;
}
- private synchronized void unregisterGammeShutdownHook() {
+ private synchronized void unregisterGammaShutdownHook() {
if (!gammaShutdownHookRegistered)
return;
if (gammaShutdownHook == null) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java
index 10c70db99..04114a445 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java
@@ -153,11 +153,9 @@ public abstract class GLDrawableImpl implements GLDrawable {
}
public String toString() {
- return getClass().getName()+"[realized "+getRealized()+
- ",\n\tfactory "+getFactory()+
- ",\n\twindow "+getNativeWindow()+
- ",\n\trequested "+getRequestedGLCapabilities()+
- ",\n\tchosen "+getChosenGLCapabilities()+"]";
+ return getClass().getName()+"[Realized "+getRealized()+
+ ",\n\tFactory "+getFactory()+
+ ",\n\tWindow "+getNativeWindow()+"]";
}
protected GLDrawableFactory factory;
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java
index ec2677559..a96736c00 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java
@@ -80,13 +80,9 @@ public abstract class EGLContext extends GLContextImpl {
return eglExtProcAddressTable;
}
- protected String mapToRealGLFunctionName(String glFunctionName) {
- return glFunctionName;
- }
+ protected Map/*<String, String>*/ getFunctionNameMap() { return null; }
- protected String mapToRealGLExtensionName(String glExtensionName) {
- return glExtensionName;
- }
+ protected Map/*<String, String>*/ getExtensionNameMap() { return null; }
public long getContext() {
return eglContext;
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 34b039b3a..5a193b2ff 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
@@ -70,7 +70,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
throw new GLException("Not yet implemented");
}
- public boolean canCreateGLPbuffer() {
+ public boolean canCreateGLPbuffer(AbstractGraphicsDevice device) {
return true;
}
@@ -89,7 +89,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
return new EGLExternalContext(absScreen);
}
- public boolean canCreateExternalGLDrawable() {
+ public boolean canCreateExternalGLDrawable(AbstractGraphicsDevice device) {
return false;
}
@@ -100,7 +100,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
public void loadGLULibrary() {
}
- public boolean canCreateContextOnJava2DSurface() {
+ public boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device) {
return false;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java
index bf4023c1c..d3a634792 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java
@@ -84,16 +84,10 @@ public abstract class MacOSXCGLContext extends GLContextImpl
return cglExtProcAddressTable;
}
- protected String mapToRealGLFunctionName(String glFunctionName)
- {
- return glFunctionName;
- }
-
- protected String mapToRealGLExtensionName(String glExtensionName)
- {
- return glExtensionName;
- }
-
+ protected Map/*<String, String>*/ getFunctionNameMap() { return null; }
+
+ protected Map/*<String, String>*/ getExtensionNameMap() { return null; }
+
protected abstract boolean create();
/**
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 641e482bc..906088642 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
@@ -71,7 +71,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl implements D
return new MacOSXOffscreenCGLDrawable(this, target);
}
- public boolean canCreateGLPbuffer() {
+ public boolean canCreateGLPbuffer(AbstractGraphicsDevice device) {
return true;
}
@@ -103,7 +103,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl implements D
return MacOSXExternalCGLContext.create(this, null);
}
- public boolean canCreateExternalGLDrawable() {
+ public boolean canCreateExternalGLDrawable(AbstractGraphicsDevice device) {
return false;
}
@@ -121,7 +121,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl implements D
return CGL.getProcAddress(glFuncName);
}
- public boolean canCreateContextOnJava2DSurface() {
+ public boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device) {
return false;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLDrawableFactory.java
index cc973c56a..eff01ca18 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLDrawableFactory.java
@@ -42,6 +42,7 @@ package com.jogamp.opengl.impl.macosx.cgl.awt;
import java.lang.reflect.InvocationTargetException;
import java.nio.*;
import java.util.*;
+import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.jogamp.opengl.impl.*;
import com.jogamp.opengl.impl.awt.*;
@@ -53,7 +54,7 @@ public class MacOSXAWTCGLDrawableFactory extends MacOSXCGLDrawableFactory {
super();
}
- public boolean canCreateContextOnJava2DSurface() {
+ public boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device) {
return true;
}
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 49e646844..87a37da04 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
@@ -46,8 +46,8 @@ import com.jogamp.nativewindow.impl.NullWindow;
public class WindowsDummyWGLDrawable extends WindowsWGLDrawable {
private long hwnd, hdc;
- public WindowsDummyWGLDrawable(GLDrawableFactory factory) {
- super(factory, new NullWindow(WindowsWGLGraphicsConfigurationFactory.createDefaultGraphicsConfiguration(null, true, true)), true);
+ public WindowsDummyWGLDrawable(GLDrawableFactory factory, GLProfile glp) {
+ super(factory, new NullWindow(WindowsWGLGraphicsConfigurationFactory.createDefaultGraphicsConfiguration(glp, null, true, true)), true);
// All entries to CreateDummyWindow must synchronize on one object
// to avoid accidentally registering the dummy window class twice
synchronized (WindowsDummyWGLDrawable.class) {
@@ -56,8 +56,9 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable {
hdc = WGL.GetDC(hwnd);
NullWindow nw = (NullWindow) getNativeWindow();
nw.setSurfaceHandle(hdc);
+ WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)nw.getGraphicsConfiguration().getNativeGraphicsConfiguration();
// Choose a (hopefully hardware-accelerated) OpenGL pixel format for this device context
- GLCapabilities caps = new GLCapabilities(null);
+ GLCapabilities caps = (GLCapabilities) config.getChosenCapabilities();
caps.setDepthBits(16);
PIXELFORMATDESCRIPTOR pfd = WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps);
int pixelFormat = WGL.ChoosePixelFormat(hdc, pfd);
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 08c77539c..b3f4c498c 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
@@ -118,21 +118,9 @@ public class WindowsWGLContext extends GLContextImpl {
return wglExtProcAddressTable;
}
- protected String mapToRealGLFunctionName(String glFunctionName) {
- String lookup = (String) functionNameMap.get(glFunctionName);
- if (lookup != null) {
- return lookup;
- }
- return glFunctionName;
- }
+ protected Map/*<String, String>*/ getFunctionNameMap() { return functionNameMap; }
- protected String mapToRealGLExtensionName(String glExtensionName) {
- String lookup = (String) extensionNameMap.get(glExtensionName);
- if (lookup != null) {
- return lookup;
- }
- return glExtensionName;
- }
+ protected Map/*<String, String>*/ getExtensionNameMap() { return extensionNameMap; }
/**
* Creates and initializes an appropriate OpenGL context. Should only be
@@ -306,7 +294,7 @@ public class WindowsWGLContext extends GLContextImpl {
if (WGL.wglGetCurrentContext() != hglrc) {
if (!wglMakeContextCurrent(drawable.getNativeWindow().getSurfaceHandle(), drawableRead.getNativeWindow().getSurfaceHandle(), hglrc)) {
- throw new GLException("Error making context current: 0x" + Integer.toHexString(WGL.GetLastError()));
+ throw new GLException("Error making context current: 0x" + Integer.toHexString(WGL.GetLastError()) + ", " + this);
} else {
if (DEBUG && VERBOSE) {
System.err.println(getThreadName() + ": wglMakeCurrent(hdc " + toHexString(drawable.getNativeWindow().getSurfaceHandle()) +
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 9e458c8d0..cb3ee19e0 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
@@ -85,12 +85,12 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
private boolean pbufferSupportInitialized = false;
private boolean canCreateGLPbuffer = false;
- public boolean canCreateGLPbuffer() {
+ public boolean canCreateGLPbuffer(AbstractGraphicsDevice device) {
if (!pbufferSupportInitialized) {
final GLDrawableFactory factory = this;
Runnable r = new Runnable() {
public void run() {
- WindowsDummyWGLDrawable dummyDrawable = new WindowsDummyWGLDrawable(factory);
+ WindowsDummyWGLDrawable dummyDrawable = new WindowsDummyWGLDrawable(factory, null);
GLContext dummyContext = dummyDrawable.createContext(null);
if (dummyContext != null) {
GLContext lastContext = GLContext.getCurrent();
@@ -123,7 +123,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
final GLDrawableFactory factory = this;
Runnable r = new Runnable() {
public void run() {
- WindowsDummyWGLDrawable dummyDrawable = new WindowsDummyWGLDrawable(factory);
+ WindowsDummyWGLDrawable dummyDrawable = new WindowsDummyWGLDrawable(factory, null);
WindowsWGLContext dummyContext = (WindowsWGLContext) dummyDrawable.createContext(null);
GLContext lastContext = GLContext.getCurrent();
if (lastContext != null) {
@@ -136,10 +136,14 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
dummyDrawable,
dummyWGLExt);
returnList.add(pbufferDrawable);
- dummyContext.release();
- dummyContext.destroy();
- dummyDrawable.destroy();
} finally {
+ if(null!=dummyContext) {
+ dummyContext.release();
+ dummyContext.destroy();
+ }
+ if(null!=dummyDrawable) {
+ dummyDrawable.destroy();
+ }
if (lastContext != null) {
lastContext.makeCurrent();
}
@@ -162,7 +166,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
return WindowsExternalWGLContext.create(this, null);
}
- public boolean canCreateExternalGLDrawable() {
+ public boolean canCreateExternalGLDrawable(AbstractGraphicsDevice device) {
return true;
}
@@ -222,7 +226,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
return detail;
}
- public boolean canCreateContextOnJava2DSurface() {
+ public boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device) {
return false;
}
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 563173682..55b30ef3a 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
@@ -58,22 +58,17 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
return chooseGraphicsConfigurationStatic(caps, chooser, absScreen);
}
- protected static WindowsWGLGraphicsConfiguration createDefaultGraphicsConfiguration(AbstractGraphicsScreen absScreen, boolean onscreen, boolean usePBuffer) {
- GLCapabilities caps = new GLCapabilities(null);
+ protected static WindowsWGLGraphicsConfiguration createDefaultGraphicsConfiguration(GLProfile glp, AbstractGraphicsScreen absScreen, boolean onscreen, boolean usePBuffer) {
+ GLCapabilities caps = new GLCapabilities(glp);
caps.setDoubleBuffered(onscreen); // FIXME DBLBUFOFFSCRN
caps.setOnscreen (onscreen);
caps.setPBuffer (usePBuffer);
- GLCapabilities caps2 = (GLCapabilities) caps.clone();
- if(!caps2.isOnscreen()) {
- // OFFSCREEN !DOUBLE_BUFFER // FIXME DBLBUFOFFSCRN
- caps2.setDoubleBuffered(false);
- }
-
if(null==absScreen) {
absScreen = DefaultGraphicsScreen.createScreenDevice(0);
}
- return new WindowsWGLGraphicsConfiguration(absScreen, caps2, caps, WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps2), -1, null);
+ return new WindowsWGLGraphicsConfiguration(absScreen, caps, caps, WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps), -1, null);
+
}
protected static WindowsWGLGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilities caps,
@@ -143,7 +138,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
GLContextImpl dummyContext = null;
WGLExt dummyWGLExt = null;
if (capabilities.getSampleBuffers()) {
- dummyDrawable = new WindowsDummyWGLDrawable(factory);
+ dummyDrawable = new WindowsDummyWGLDrawable(factory, glProfile);
dummyContext = (GLContextImpl) dummyDrawable.createContext(null);
if (dummyContext != null) {
dummyContext.makeCurrent();
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
new file mode 100644
index 000000000..097689967
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2010 Sven Gothel. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name Sven Gothel or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+package com.jogamp.opengl.impl.x11.glx;
+
+import javax.media.opengl.*;
+import com.jogamp.opengl.impl.*;
+
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.x11.*;
+import com.jogamp.nativewindow.impl.*;
+import com.jogamp.nativewindow.impl.x11.*;
+
+public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable {
+
+ /**
+ * Due to the ATI Bug https://bugzilla.mozilla.org/show_bug.cgi?id=486277,
+ * we cannot switch the Display as we please,
+ * hence we reuse the target's screen configuration.
+ */
+ public X11DummyGLXDrawable(X11GraphicsScreen screen, GLDrawableFactory factory, GLProfile glp) {
+ super(factory,
+ new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
+ new GLCapabilities(glp), null, screen)));
+ this.realized = true;
+
+ NullWindow nw = (NullWindow) getNativeWindow();
+ X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)nw.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ GLCapabilities caps = (GLCapabilities) config.getChosenCapabilities();
+
+ long dpy = config.getScreen().getDevice().getHandle();
+ int scrn = config.getScreen().getIndex();
+ // System.out.println("X11DummyGLXDrawable: dpy "+toHexString(dpy)+", scrn "+scrn);
+ X11Lib.XLockDisplay(dpy);
+ try{
+ nw.setSurfaceHandle( X11Lib.RootWindow(dpy, scrn) );
+ } finally {
+ X11Lib.XUnlockDisplay(dpy);
+ }
+ }
+
+ public void setSize(int width, int height) {
+ }
+
+ public int getWidth() {
+ return 1;
+ }
+
+ public int getHeight() {
+ return 1;
+ }
+
+ public void destroy() {
+ // nothing to do, but allowed
+ }
+}
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 ce846c0a4..055e7236c 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
@@ -54,6 +54,7 @@ public abstract class X11GLXContext extends GLContextImpl {
private boolean glXQueryExtensionsStringInitialized;
private boolean glXQueryExtensionsStringAvailable;
private static final Map/*<String, String>*/ functionNameMap;
+ private static final Map/*<String, String>*/ extensionNameMap;
private GLXExt glXExt;
// Table that holds the addresses of the native C-language entry points for
// GLX extension functions.
@@ -63,6 +64,10 @@ public abstract class X11GLXContext extends GLContextImpl {
functionNameMap = new HashMap();
functionNameMap.put("glAllocateMemoryNV", "glXAllocateMemoryNV");
functionNameMap.put("glFreeMemoryNV", "glXFreeMemoryNV");
+
+ extensionNameMap = new HashMap();
+ extensionNameMap.put("GL_ARB_pbuffer", "GLX_SGIX_pbuffer");
+ extensionNameMap.put("GL_ARB_pixel_format", "GLX_SGIX_pbuffer"); // good enough
}
public X11GLXContext(GLDrawableImpl drawable, GLDrawableImpl drawableRead,
@@ -94,17 +99,9 @@ public abstract class X11GLXContext extends GLContextImpl {
return glXExt;
}
- protected String mapToRealGLFunctionName(String glFunctionName) {
- String lookup = (String) functionNameMap.get(glFunctionName);
- if (lookup != null) {
- return lookup;
- }
- return glFunctionName;
- }
+ protected Map/*<String, String>*/ getFunctionNameMap() { return functionNameMap; }
- protected String mapToRealGLExtensionName(String glExtensionName) {
- return glExtensionName;
- }
+ protected Map/*<String, String>*/ getExtensionNameMap() { return extensionNameMap; }
/** Helper routine which usually just turns around and calls
* createContext (except for pbuffers, which use a different context
@@ -363,7 +360,7 @@ public abstract class X11GLXContext extends GLContextImpl {
drawable.getNativeWindow().getSurfaceHandle(),
drawableRead.getNativeWindow().getSurfaceHandle(),
context)) {
- throw new GLException("Error making context current");
+ throw new GLException("Error making context current: "+this);
}
if (DEBUG && (VERBOSE || created)) {
System.err.println(getThreadName() + ": glXMakeCurrent(display " +
@@ -485,7 +482,8 @@ public abstract class X11GLXContext extends GLContextImpl {
public boolean isExtensionAvailable(String glExtensionName) {
if (glExtensionName.equals("GL_ARB_pbuffer") ||
glExtensionName.equals("GL_ARB_pixel_format")) {
- return getGLDrawable().getFactory().canCreateGLPbuffer();
+ return getGLDrawable().getFactory().canCreateGLPbuffer(
+ drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice() );
}
return super.isExtensionAvailable(glExtensionName);
}
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 1a254843e..60ee431dc 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
@@ -73,14 +73,29 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
return new X11OffscreenGLXDrawable(this, target);
}
- private boolean pbufferSupportInitialized = false;
- private boolean canCreateGLPbuffer = false;
- public boolean canCreateGLPbuffer() {
- if (!pbufferSupportInitialized) {
- long display = X11Util.getThreadLocalDefaultDisplay();
+ public boolean canCreateGLPbuffer(AbstractGraphicsDevice device) {
+ return glxVersionGreaterEqualThan(device, 1, 3);
+ }
+
+ private boolean glxVersionsQueried = false;
+ private int glxVersionMajor=0, glxVersionMinor=0;
+ public boolean glxVersionGreaterEqualThan(AbstractGraphicsDevice device, int majorReq, int minorReq) {
+ if (!glxVersionsQueried) {
+ if(null == device) {
+ GLContext ctx = GLContext.getCurrent();
+ if( null != ctx) {
+ device = ctx.getGLDrawable().getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice();
+ }
+ }
+ if(null == device) {
+ GLException gle = new GLException("FIXME: No AbstractGraphicsDevice (passed or queried via current context - Fallback to ThreadLocal Display ..");
+ gle.printStackTrace();
+
+ device = new X11GraphicsDevice(X11Util.getThreadLocalDisplay(null));
+ }
+ long display = device.getHandle();
int[] major = new int[1];
int[] minor = new int[1];
- int screen = 0; // FIXME: provide way to specify this?
if (!GLX.glXQueryVersion(display, major, 0, minor, 0)) {
throw new GLException("glXQueryVersion failed");
@@ -94,34 +109,51 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
// only implement GLX version 1.2 on the server side
if (major[0] == 1 && minor[0] == 2) {
String str = GLX.glXGetClientString(display, GLX.GLX_VERSION);
- if (str != null && str.startsWith("1.") &&
- (str.charAt(2) >= '3')) {
- canCreateGLPbuffer = true;
+ try {
+ major[0] = Integer.valueOf(str.substring(0, 1)).intValue();
+ minor[0] = Integer.valueOf(str.substring(2, 3)).intValue();
+ } catch (NumberFormatException nfe) {
+ major[0] = 1;
+ minor[0] = 2;
}
- } else {
- canCreateGLPbuffer = ((major[0] > 1) || (minor[0] > 2));
}
- pbufferSupportInitialized = true;
+ glxVersionMajor = major[0];
+ glxVersionMinor = minor[0];
+ glxVersionsQueried = true;
}
- return canCreateGLPbuffer;
+ return ( glxVersionMajor > majorReq ) || ( glxVersionMajor == majorReq && glxVersionMinor >= minorReq ) ;
}
protected GLDrawableImpl createGLPbufferDrawableImpl(final NativeWindow target) {
+ GLDrawableImpl pbufferDrawable;
+ X11DummyGLXDrawable dummyDrawable=null;
+ GLContext dummyContext=null;
+
/**
- * FIXME: Think about this ..
- * should not be necessary ? ..
- final List returnList = new ArrayList();
- final GLDrawableFactory factory = this;
- Runnable r = new Runnable() {
- public void run() {
- returnList.add(new X11PbufferGLXDrawable(factory, target));
+ * Due to the ATI Bug https://bugzilla.mozilla.org/show_bug.cgi?id=486277,
+ * we need to have a context current on the same Display to create a PBuffer.
+ * The dummy context shall also use the same Display,
+ * since switching Display in this regard is another ATI bug.
+ */
+ if( null == GLContext.getCurrent() ) {
+ X11GraphicsScreen screen = (X11GraphicsScreen) target.getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen();
+ dummyDrawable = new X11DummyGLXDrawable(screen, this, null);
+ dummyContext = dummyDrawable.createContext(null);
+ dummyContext.makeCurrent();
+ }
+ try {
+ pbufferDrawable = new X11PbufferGLXDrawable(this, target);
+ } finally {
+ if(null!=dummyContext) {
+ dummyContext.release();
+ dummyContext.destroy();
}
- };
- maybeDoSingleThreadedWorkaround(r);
- return (GLDrawableImpl) returnList.get(0);
- */
- return new X11PbufferGLXDrawable(this, target);
+ if(null!=dummyDrawable) {
+ dummyDrawable.destroy();
+ }
+ }
+ return pbufferDrawable;
}
@@ -136,8 +168,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
return X11ExternalGLXContext.create(this, null);
}
- public boolean canCreateExternalGLDrawable() {
- return canCreateGLPbuffer();
+ public boolean canCreateExternalGLDrawable(AbstractGraphicsDevice device) {
+ return canCreateGLPbuffer(device);
}
public GLDrawable createExternalGLDrawable() {
@@ -158,7 +190,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
return res;
}
- public boolean canCreateContextOnJava2DSurface() {
+ public boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device) {
return false;
}
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 16e341652..72551f928 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
@@ -59,7 +59,8 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
return chooseGraphicsConfigurationStatic(capabilities, chooser, absScreen);
}
- protected static X11GLXGraphicsConfiguration createDefaultGraphicsConfiguration(AbstractGraphicsScreen absScreen, boolean onscreen, boolean usePBuffer) {
+ /**
+ protected static X11GLXGraphicsConfiguration createDefaultGraphicsConfigurationFBConfig(AbstractGraphicsScreen absScreen, boolean onscreen, boolean usePBuffer) {
if (absScreen == null) {
throw new IllegalArgumentException("AbstractGraphicsScreen is null");
}
@@ -110,7 +111,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
}
return new X11GLXGraphicsConfiguration(x11Screen, (null!=capsFB)?capsFB:caps, caps, null, xvis, fbcfg, fbid);
- }
+ } */
protected static X11GLXGraphicsConfiguration chooseGraphicsConfigurationStatic(Capabilities capabilities,
CapabilitiesChooser chooser,