aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/impl/x11/glx
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/impl/x11/glx')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/GLXUtil.java29
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java13
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXContext.java56
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXDrawable.java77
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java216
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawable.java31
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java128
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDynamicLibraryBundleInfo.java88
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDynamicLookupHelper.java113
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java24
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java301
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java103
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXContext.java14
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java45
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXContext.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXDrawable.java18
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java80
18 files changed, 566 insertions, 778 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/GLXUtil.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/GLXUtil.java
index 804a262fe..ddcac9628 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/GLXUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/GLXUtil.java
@@ -37,28 +37,25 @@ import javax.media.opengl.*;
import com.jogamp.nativewindow.impl.x11.*;
public class GLXUtil {
- public static boolean isMultisampleAvailable(long display) {
- X11Util.XLockDisplay(display);
- try {
- String exts = GLX.glXGetClientString(display, GLX.GLX_EXTENSIONS);
- if (exts != null) {
- return (exts.indexOf("GLX_ARB_multisample") >= 0);
- }
- return false;
- } finally {
- X11Util.XUnlockDisplay(display);
+ public static String getExtension(long display) {
+ return GLX.glXGetClientString(display, GLX.GLX_EXTENSIONS);
+ }
+
+ public static boolean isMultisampleAvailable(String extensions) {
+ if (extensions != null) {
+ return (extensions.indexOf("GLX_ARB_multisample") >= 0);
}
+ return false;
+ }
+
+ public static boolean isMultisampleAvailable(long display) {
+ return isMultisampleAvailable(getExtension(display));
}
/** Workaround for apparent issue with ATI's proprietary drivers
where direct contexts still send GLX tokens for GL calls */
public static String getVendorName(long display) {
- X11Util.XLockDisplay(display);
- try {
- return GLX.glXGetClientString(display, GLX.GLX_VENDOR);
- } finally {
- X11Util.XUnlockDisplay(display);
- }
+ return GLX.glXGetClientString(display, GLX.GLX_VENDOR);
}
public static boolean isVendorNVIDIA(String vendor) {
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 03783f3b9..afd005bb4 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
@@ -64,13 +64,10 @@ public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable {
int scrn = screen.getIndex();
long visualID = config.getVisualID();
- X11Util.XLockDisplay(dpy);
- try{
- dummyWindow = X11Lib.CreateDummyWindow(dpy, scrn, visualID);
- } finally {
- X11Util.XUnlockDisplay(dpy);
- }
+ dummyWindow = X11Lib.CreateDummyWindow(dpy, scrn, visualID);
nw.setSurfaceHandle( dummyWindow );
+
+ updateHandle();
}
public void setSize(int width, int height) {
@@ -86,9 +83,9 @@ public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable {
public void destroy() {
if(0!=dummyWindow) {
+ destroyHandle();
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- long dpy = config.getScreen().getDevice().getHandle();
- X11Lib.DestroyDummyWindow(dpy, dummyWindow);
+ X11Lib.DestroyDummyWindow(config.getScreen().getDevice().getHandle(), dummyWindow);
}
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXContext.java
index 8792ac08e..a1e4585f7 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXContext.java
@@ -59,36 +59,32 @@ public class X11ExternalGLXContext extends X11GLXContext {
}
protected static X11ExternalGLXContext create(GLDrawableFactory factory, GLProfile glp) {
- ((GLDrawableFactoryImpl)factory).lockToolkit();
- try {
- long ctx = GLX.glXGetCurrentContext();
- if (ctx == 0) {
- throw new GLException("Error: current context null");
- }
- long display = GLX.glXGetCurrentDisplay();
- if (display == 0) {
- throw new GLException("Error: current display null");
- }
- long drawable = GLX.glXGetCurrentDrawable();
- if (drawable == 0) {
- throw new GLException("Error: attempted to make an external GLDrawable without a drawable/context current");
- }
- int[] val = new int[1];
- GLX.glXQueryContext(display, ctx, GLX.GLX_SCREEN, val, 0);
- X11GraphicsScreen x11Screen = (X11GraphicsScreen) X11GraphicsScreen.createScreenDevice(display, val[0]);
-
- GLX.glXQueryContext(display, ctx, GLX.GLX_FBCONFIG_ID, val, 0);
- X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfiguration.create(glp, x11Screen, val[0]);
-
- NullWindow nw = new NullWindow(cfg);
- nw.setSurfaceHandle(drawable);
- return new X11ExternalGLXContext(new Drawable(factory, nw), ctx);
- } finally {
- ((GLDrawableFactoryImpl)factory).unlockToolkit();
+ long ctx = GLX.glXGetCurrentContext();
+ if (ctx == 0) {
+ throw new GLException("Error: current context null");
}
+ long display = GLX.glXGetCurrentDisplay();
+ if (display == 0) {
+ throw new GLException("Error: current display null");
+ }
+ long drawable = GLX.glXGetCurrentDrawable();
+ if (drawable == 0) {
+ throw new GLException("Error: attempted to make an external GLDrawable without a drawable/context current");
+ }
+ int[] val = new int[1];
+ GLX.glXQueryContext(display, ctx, GLX.GLX_SCREEN, val, 0);
+ X11GraphicsScreen x11Screen = (X11GraphicsScreen) X11GraphicsScreen.createScreenDevice(display, val[0]);
+
+ GLX.glXQueryContext(display, ctx, GLX.GLX_FBCONFIG_ID, val, 0);
+ X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfiguration.create(glp, x11Screen, val[0]);
+
+ NullWindow nw = new NullWindow(cfg);
+ nw.setSurfaceHandle(drawable);
+ return new X11ExternalGLXContext(new Drawable(factory, nw), ctx);
}
- protected void create() {
+ protected boolean createImpl() {
+ return true;
}
public int makeCurrent() throws GLException {
@@ -108,20 +104,16 @@ public class X11ExternalGLXContext extends X11GLXContext {
lastContext = null;
}
- protected int makeCurrentImpl() throws GLException {
+ protected void makeCurrentImpl(boolean newCreated) throws GLException {
if (firstMakeCurrent) {
firstMakeCurrent = false;
- return CONTEXT_CURRENT_NEW;
}
- return CONTEXT_CURRENT;
}
protected void releaseImpl() throws GLException {
}
protected void destroyImpl() throws GLException {
- contextHandle = 0;
- GLContextShareSet.contextDestroyed(this);
}
// Need to provide the display connection to extension querying APIs
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXDrawable.java
index f10bd38c6..8a8702a3e 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXDrawable.java
@@ -62,46 +62,41 @@ public class X11ExternalGLXDrawable extends X11GLXDrawable {
}
protected static X11ExternalGLXDrawable create(GLDrawableFactory factory, GLProfile glp) {
- ((GLDrawableFactoryImpl)factory).lockToolkit();
- try {
- long context = GLX.glXGetCurrentContext();
- if (context == 0) {
- throw new GLException("Error: current context null");
- }
- long display = GLX.glXGetCurrentDisplay();
- if (display == 0) {
- throw new GLException("Error: current display null");
- }
- long drawable = GLX.glXGetCurrentDrawable();
- if (drawable == 0) {
- throw new GLException("Error: attempted to make an external GLDrawable without a drawable current");
- }
- int[] val = new int[1];
- GLX.glXQueryContext(display, context, GLX.GLX_SCREEN, val, 0);
- X11GraphicsScreen x11Screen = (X11GraphicsScreen) X11GraphicsScreen.createScreenDevice(display, val[0]);
-
- GLX.glXQueryContext(display, context, GLX.GLX_FBCONFIG_ID, val, 0);
- X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfiguration.create(glp, x11Screen, val[0]);
-
- int w, h;
- GLX.glXQueryDrawable(display, drawable, GLX.GLX_WIDTH, val, 0);
- w=val[0];
- GLX.glXQueryDrawable(display, drawable, GLX.GLX_HEIGHT, val, 0);
- h=val[0];
-
- GLX.glXQueryContext(display, context, GLX.GLX_RENDER_TYPE, val, 0);
- if ((val[0] & GLX.GLX_RGBA_TYPE) == 0) {
- if (DEBUG) {
- System.err.println("X11ExternalGLXDrawable: WARNING: forcing GLX_RGBA_TYPE for newly created contexts (current 0x"+Integer.toHexString(val[0])+")");
- }
- }
- NullWindow nw = new NullWindow(cfg);
- nw.setSurfaceHandle(drawable);
- nw.setSize(w, h);
- return new X11ExternalGLXDrawable(factory, nw, GLX.GLX_RGBA_TYPE);
- } finally {
- ((GLDrawableFactoryImpl)factory).unlockToolkit();
+ long context = GLX.glXGetCurrentContext();
+ if (context == 0) {
+ throw new GLException("Error: current context null");
}
+ long display = GLX.glXGetCurrentDisplay();
+ if (display == 0) {
+ throw new GLException("Error: current display null");
+ }
+ long drawable = GLX.glXGetCurrentDrawable();
+ if (drawable == 0) {
+ throw new GLException("Error: attempted to make an external GLDrawable without a drawable current");
+ }
+ int[] val = new int[1];
+ GLX.glXQueryContext(display, context, GLX.GLX_SCREEN, val, 0);
+ X11GraphicsScreen x11Screen = (X11GraphicsScreen) X11GraphicsScreen.createScreenDevice(display, val[0]);
+
+ GLX.glXQueryContext(display, context, GLX.GLX_FBCONFIG_ID, val, 0);
+ X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfiguration.create(glp, x11Screen, val[0]);
+
+ int w, h;
+ GLX.glXQueryDrawable(display, drawable, GLX.GLX_WIDTH, val, 0);
+ w=val[0];
+ GLX.glXQueryDrawable(display, drawable, GLX.GLX_HEIGHT, val, 0);
+ h=val[0];
+
+ GLX.glXQueryContext(display, context, GLX.GLX_RENDER_TYPE, val, 0);
+ if ((val[0] & GLX.GLX_RGBA_TYPE) == 0) {
+ if (DEBUG) {
+ System.err.println("X11ExternalGLXDrawable: WARNING: forcing GLX_RGBA_TYPE for newly created contexts (current 0x"+Integer.toHexString(val[0])+")");
+ }
+ }
+ NullWindow nw = new NullWindow(cfg);
+ nw.setSurfaceHandle(drawable);
+ nw.setSize(w, h);
+ return new X11ExternalGLXDrawable(factory, nw, GLX.GLX_RGBA_TYPE);
}
public GLContext createContext(GLContext shareWith) {
@@ -125,8 +120,8 @@ public class X11ExternalGLXDrawable extends X11GLXDrawable {
super(drawable, shareWith);
}
- protected void create() {
- createContext(true);
+ protected boolean createImpl() {
+ return createContext(true);
}
}
}
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 baca6bfa4..baa6ce1aa 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
@@ -60,6 +60,11 @@ public abstract class X11GLXContext extends GLContextImpl {
// GLX extension functions.
private GLXExtProcAddressTable glXExtProcAddressTable;
+ // This indicates whether the context we have created is indirect
+ // and therefore requires the toolkit to be locked around all GL
+ // calls rather than just all GLX calls
+ protected boolean isDirect;
+
static {
functionNameMap = new HashMap();
functionNameMap.put("glAllocateMemoryNV", "glXAllocateMemoryNV");
@@ -193,10 +198,7 @@ public abstract class X11GLXContext extends GLContextImpl {
}
}
if(0!=ctx) {
- if (!glXMakeContextCurrent(display,
- drawable.getNativeWindow().getSurfaceHandle(),
- drawableRead.getNativeWindow().getSurfaceHandle(),
- ctx)) {
+ if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), ctx)) {
if(DEBUG) {
System.err.println("X11GLXContext.createContextARB couldn't make current "+getGLVersion(major, minor, ctp, "@creation"));
}
@@ -213,10 +215,8 @@ public abstract class X11GLXContext extends GLContextImpl {
* called by {@link #create()}.
* Note: The direct parameter may be overwritten by the direct state of a shared context.
*/
- protected void createContext(boolean direct) {
- if(0!=contextHandle) {
- throw new GLException("context is not null: "+contextHandle);
- }
+ protected boolean createContext(boolean direct) {
+ isDirect = false; // default
X11GLXDrawableFactory factory = (X11GLXDrawableFactory)drawable.getFactoryImpl();
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
long display = config.getScreen().getDevice().getHandle();
@@ -244,14 +244,12 @@ public abstract class X11GLXContext extends GLContextImpl {
if (contextHandle == 0) {
throw new GLException("Unable to create context(0)");
}
- if (!glXMakeContextCurrent(display,
- drawable.getNativeWindow().getSurfaceHandle(),
- drawableRead.getNativeWindow().getSurfaceHandle(),
- contextHandle)) {
+ if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
throw new GLException("Error making temp context(0) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable);
}
setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY); // use GL_VERSION
- return;
+ isDirect = GLX.glXIsDirect(display, contextHandle);
+ return true;
}
int minor[] = new int[1];
@@ -276,17 +274,14 @@ public abstract class X11GLXContext extends GLContextImpl {
if (temp_ctx == 0) {
throw new GLException("Unable to create temp OpenGL context(1)");
}
- if (!glXMakeContextCurrent(display,
- drawable.getNativeWindow().getSurfaceHandle(),
- drawableRead.getNativeWindow().getSurfaceHandle(),
- temp_ctx)) {
+ if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), temp_ctx)) {
throw new GLException("Error making temp context(1) current: display "+toHexString(display)+", context "+toHexString(temp_ctx)+", drawable "+drawable);
}
setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY); // use GL_VERSION
if( createContextARBTried ||
- !isFunctionAvailable("glXCreateContextAttribsARB") /* ||
- !isExtensionAvailable("GLX_ARB_create_context") */ ) { // unresolved case where client version is 1.4 without this extension
+ !isFunctionAvailable("glXCreateContextAttribsARB") ||
+ !isExtensionAvailable("GLX_ARB_create_context") ) {
if(glp.isGL3()) {
glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_ctx);
@@ -298,7 +293,8 @@ public abstract class X11GLXContext extends GLContextImpl {
// continue with temp context for GL < 3.0
contextHandle = temp_ctx;
- return;
+ isDirect = GLX.glXIsDirect(display, contextHandle);
+ return true;
}
contextHandle = createContextARB(share, direct, major, minor, ctp);
createContextARBTried=true;
@@ -308,10 +304,7 @@ public abstract class X11GLXContext extends GLContextImpl {
if(0!=temp_ctx) {
glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_ctx);
- if (!glXMakeContextCurrent(display,
- drawable.getNativeWindow().getSurfaceHandle(),
- drawableRead.getNativeWindow().getSurfaceHandle(),
- contextHandle)) {
+ if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
throw new GLException("Cannot make previous verified context current");
}
}
@@ -327,146 +320,63 @@ public abstract class X11GLXContext extends GLContextImpl {
// continue with temp context for GL <= 3.0
contextHandle = temp_ctx;
- if (!glXMakeContextCurrent(display,
- drawable.getNativeWindow().getSurfaceHandle(),
- drawableRead.getNativeWindow().getSurfaceHandle(),
- contextHandle)) {
+ if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_ctx);
throw new GLException("Error making context(1) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable);
}
}
+ isDirect = GLX.glXIsDirect(display, contextHandle);
+ return true;
}
- // Note: Usually the surface shall be locked within [makeCurrent .. swap .. release]
- protected int makeCurrentImpl() throws GLException {
- boolean exceptionOccurred = false;
- int lockRes = drawable.lockSurface();
- try {
- if (lockRes == NativeWindow.LOCK_SURFACE_NOT_READY) {
- return CONTEXT_NOT_CURRENT;
- }
- if (0 == drawable.getNativeWindow().getSurfaceHandle()) {
- throw new GLException("drawable has invalid surface handle: "+drawable);
- }
- return makeCurrentImplAfterLock();
- } catch (RuntimeException e) {
- exceptionOccurred = true;
- throw e;
- } finally {
- if (exceptionOccurred ||
- (isOptimizable() && lockRes != NativeWindow.LOCK_SURFACE_NOT_READY) && drawable.isSurfaceLocked()) {
- drawable.unlockSurface();
- }
- }
- }
-
- // Note: Usually the surface shall be locked within [makeCurrent .. swap .. release]
- protected void releaseImpl() throws GLException {
- try {
- releaseImplAfterLock();
- } finally {
- if (!isOptimizable() && drawable.isSurfaceLocked()) {
- drawable.unlockSurface();
- }
- }
- }
-
- protected int makeCurrentImplAfterLock() throws GLException {
+ protected void makeCurrentImpl(boolean newCreated) throws GLException {
long dpy = drawable.getNativeWindow().getDisplayHandle();
- getDrawableImpl().getFactoryImpl().lockToolkit();
- try {
- boolean newCreated = false;
- if (!isCreated()) {
- create(); // throws exception if fails!
- newCreated = true;
- GLContextShareSet.contextCreated(this);
- if (DEBUG) {
- System.err.println(getThreadName() + ": !!! Created GL context " + toHexString(contextHandle) + " for " + getClass().getName());
- }
- }
-
- if (GLX.glXGetCurrentContext() != contextHandle) {
-
- if (!glXMakeContextCurrent(dpy,
- drawable.getNativeWindow().getSurfaceHandle(),
- drawableRead.getNativeWindow().getSurfaceHandle(),
- contextHandle)) {
- throw new GLException("Error making context current: "+this);
- }
- if (DEBUG && (VERBOSE || isCreated())) {
- System.err.println(getThreadName() + ": glXMakeCurrent(display " +
- toHexString(dpy)+
- ", drawable " + toHexString(drawable.getNativeWindow().getSurfaceHandle()) +
- ", drawableRead " + toHexString(drawableRead.getNativeWindow().getSurfaceHandle()) +
- ", context " + toHexString(contextHandle) + ") succeeded");
- }
+ if (GLX.glXGetCurrentContext() != contextHandle) {
+ if (!glXMakeContextCurrent(dpy, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
+ throw new GLException("Error making context current: "+this);
}
-
- if(newCreated) {
- setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
- return CONTEXT_CURRENT_NEW;
+ if (DEBUG && (VERBOSE || isCreated())) {
+ System.err.println(getThreadName() + ": glXMakeCurrent(display " +
+ toHexString(dpy)+
+ ", drawable " + toHexString(drawable.getHandle()) +
+ ", drawableRead " + toHexString(drawableRead.getHandle()) +
+ ", context " + toHexString(contextHandle) + ") succeeded");
}
- return CONTEXT_CURRENT;
- } finally {
- getDrawableImpl().getFactoryImpl().unlockToolkit();
}
}
- protected void releaseImplAfterLock() throws GLException {
- X11GLXDrawableFactory factory = (X11GLXDrawableFactory)drawable.getFactoryImpl();
- factory.lockToolkit();
- try {
- if (!glXMakeContextCurrent(drawable.getNativeWindow().getDisplayHandle(), 0, 0, 0)) {
- throw new GLException("Error freeing OpenGL context");
- }
- } finally {
- factory.unlockToolkit();
+ protected void releaseImpl() throws GLException {
+ long display = drawable.getNativeWindow().getDisplayHandle();
+ if (!glXMakeContextCurrent(display, 0, 0, 0)) {
+ throw new GLException("Error freeing OpenGL context");
}
}
protected void destroyImpl() throws GLException {
- getDrawableImpl().getFactoryImpl().lockToolkit();
- try {
- if (contextHandle != 0) {
- if (DEBUG) {
- System.err.println("glXDestroyContext(" +
- toHexString(drawable.getNativeWindow().getDisplayHandle()) +
- ", " +
- toHexString(contextHandle) + ")");
- }
- GLX.glXDestroyContext(drawable.getNativeWindow().getDisplayHandle(), contextHandle);
- if (DEBUG) {
- System.err.println("!!! Destroyed OpenGL context " + contextHandle);
- }
- contextHandle = 0;
- GLContextShareSet.contextDestroyed(this);
- }
- } finally {
- getDrawableImpl().getFactoryImpl().unlockToolkit();
+ long display = drawable.getNativeWindow().getDisplayHandle();
+ if (DEBUG) {
+ System.err.println("glXDestroyContext(dpy " +
+ toHexString(display)+
+ ", ctx " +
+ toHexString(contextHandle) + ")");
+ }
+ GLX.glXDestroyContext(display, contextHandle);
+ if (DEBUG) {
+ System.err.println("!!! Destroyed OpenGL context " + contextHandle);
}
}
- public void copy(GLContext source, int mask) throws GLException {
+ protected void copyImpl(GLContext source, int mask) throws GLException {
long dst = getHandle();
long src = source.getHandle();
- if (src == 0) {
- throw new GLException("Source OpenGL context has not been created");
- }
- if (dst == 0) {
- throw new GLException("Destination OpenGL context has not been created");
- }
- if (drawable.getNativeWindow().getDisplayHandle() == 0) {
+ long display = drawable.getNativeWindow().getDisplayHandle();
+ if (0 == display) {
throw new GLException("Connection to X display not yet set up");
}
- getDrawableImpl().getFactoryImpl().lockToolkit();
- try {
- GLX.glXCopyContext(drawable.getNativeWindow().getDisplayHandle(), src, dst, mask);
- // Should check for X errors and raise GLException
- } finally {
- getDrawableImpl().getFactoryImpl().unlockToolkit();
- }
+ GLX.glXCopyContext(display, src, dst, mask);
+ // Should check for X errors and raise GLException
}
protected void updateGLProcAddressTable(int major, int minor, int ctp) {
@@ -492,18 +402,13 @@ public abstract class X11GLXContext extends GLContextImpl {
glXQueryExtensionsStringInitialized = true;
}
if (glXQueryExtensionsStringAvailable) {
- GLDrawableFactoryImpl factory = getDrawableImpl().getFactoryImpl();
- factory.lockToolkit();
- try {
+ long display = drawable.getNativeWindow().getDisplayHandle();
String ret = GLX.glXQueryExtensionsString(drawable.getNativeWindow().getDisplayHandle(),
drawable.getNativeWindow().getScreenIndex());
if (DEBUG) {
System.err.println("!!! GLX extensions: " + ret);
}
return ret;
- } finally {
- factory.unlockToolkit();
- }
} else {
return "";
}
@@ -526,10 +431,9 @@ public abstract class X11GLXContext extends GLContextImpl {
GLCapabilities glCaps = (GLCapabilities) config.getChosenCapabilities();
if(!glCaps.isOnscreen()) return;
- getDrawableImpl().getFactoryImpl().lockToolkit();
- try {
- GLXExt glXExt = getGLXExt();
- if(0==hasSwapIntervalSGI) {
+ long display = drawable.getNativeWindow().getDisplayHandle();
+ GLXExt glXExt = getGLXExt();
+ if(0==hasSwapIntervalSGI) {
try {
hasSwapIntervalSGI = glXExt.isExtensionAvailable("GLX_SGI_swap_control")?1:-1;
} catch (Throwable t) { hasSwapIntervalSGI=1; }
@@ -540,9 +444,6 @@ public abstract class X11GLXContext extends GLContextImpl {
currentSwapInterval = interval;
}
} catch (Throwable t) { hasSwapIntervalSGI=-1; }
- }
- } finally {
- getDrawableImpl().getFactoryImpl().unlockToolkit();
}
}
@@ -570,8 +471,15 @@ public abstract class X11GLXContext extends GLContextImpl {
throw new GLException("Should not call this");
}
- public boolean isOptimizable() {
- return (super.isOptimizable() && !isVendorATI);
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(getClass().getName());
+ sb.append(" [");
+ super.append(sb);
+ sb.append(", direct ");
+ sb.append(isDirect);
+ sb.append("] ");
+ return sb.toString();
}
//----------------------------------------------------------------------
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawable.java
index e943abc43..25cfcc723 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawable.java
@@ -42,7 +42,7 @@ package com.jogamp.opengl.impl.x11.glx;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.jogamp.opengl.impl.*;
-import com.jogamp.common.os.DynamicLookupHelper;
+import com.jogamp.nativewindow.impl.x11.*;
public abstract class X11GLXDrawable extends GLDrawableImpl {
protected X11GLXDrawable(GLDrawableFactory factory, NativeWindow comp, boolean realized) {
@@ -50,45 +50,22 @@ public abstract class X11GLXDrawable extends GLDrawableImpl {
}
public GLDynamicLookupHelper getGLDynamicLookupHelper() {
- return X11GLXDynamicLookupHelper.getX11GLXDynamicLookupHelper();
+ return getFactoryImpl().getGLDynamicLookupHelper(0);
}
protected void setRealizedImpl() {
- if(!realized) {
- return; // nothing to do
- }
-
- if(NativeWindow.LOCK_SURFACE_NOT_READY == lockSurface()) {
- throw new GLException("X11GLXDrawable.setRealized(true): lockSurface - surface not ready");
- }
- try {
+ if(realized) {
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
config.updateGraphicsConfiguration();
if (DEBUG) {
System.err.println("!!! X11GLXDrawable.setRealized(true): "+config);
}
- } finally {
- unlockSurface();
}
}
protected void swapBuffersImpl() {
- boolean didLock = false;
- if (!isSurfaceLocked()) {
- // Usually the surface shall be locked within [makeCurrent .. swap .. release]
- if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) {
- return;
- }
- didLock = true;
- }
- try {
- GLX.glXSwapBuffers(component.getDisplayHandle(), component.getSurfaceHandle());
- } finally {
- if (didLock) {
- unlockSurface();
- }
- }
+ GLX.glXSwapBuffers(getNativeWindow().getDisplayHandle(), 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 fe2176f61..822a3d0b3 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
@@ -49,17 +49,31 @@ import com.jogamp.nativewindow.impl.x11.*;
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());
+ } catch (GLException gle) {
+ if(DEBUG) {
+ gle.printStackTrace();
+ }
+ }
+ x11GLXDynamicLookupHelper = tmp;
+ if(null!=x11GLXDynamicLookupHelper) {
+ GLX.getGLXProcAddressTable().reset(x11GLXDynamicLookupHelper);
+ }
}
public GLDynamicLookupHelper getGLDynamicLookupHelper(int profile) {
- return X11GLXDynamicLookupHelper.getX11GLXDynamicLookupHelper();
+ return x11GLXDynamicLookupHelper;
}
public X11GLXDrawableFactory() {
super();
- X11GLXDynamicLookupHelper.getX11GLXDynamicLookupHelper(); // ensure it's loaded and setup
// Register our GraphicsConfigurationFactory implementations
// The act of constructing them causes them to be registered
new X11GLXGraphicsConfigurationFactory();
@@ -75,12 +89,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
isVendorATI = GLXUtil.isVendorATI(vendorName);
isVendorNVIDIA = GLXUtil.isVendorNVIDIA(vendorName);
sharedScreen = new X11GraphicsScreen(sharedDevice, 0);
- X11Util.XLockDisplay(tlsDisplay);
- try{
- sharedDrawable = new X11DummyGLXDrawable(sharedScreen, X11GLXDrawableFactory.this, GLProfile.getDefault());
- } finally {
- X11Util.XUnlockDisplay(tlsDisplay);
- }
+ sharedDrawable = new X11DummyGLXDrawable(sharedScreen, X11GLXDrawableFactory.this, GLProfile.getDefault());
if(isVendorATI() && GLProfile.isAWTAvailable()) {
X11Util.markThreadLocalDisplayUncloseable(tlsDisplay); // failure to close with ATI and AWT usage
}
@@ -89,7 +98,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
}
// We have to keep this within this thread,
// since we have a 'chicken-and-egg' problem otherwise on the <init> lock of this thread.
- X11Util.XLockDisplay(sharedScreen.getDevice().getHandle());
try{
X11GLXContext ctx = (X11GLXContext) sharedDrawable.createContext(null);
ctx.makeCurrent();
@@ -97,8 +105,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
sharedContext = ctx;
} catch (Throwable t) {
throw new GLException("X11GLXDrawableFactory - Could not initialize shared resources", t);
- } finally {
- X11Util.XUnlockDisplay(sharedScreen.getDevice().getHandle());
}
if(null==sharedContext) {
throw new GLException("X11GLXDrawableFactory - Shared Context is null");
@@ -137,13 +143,15 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
System.err.println("!!! Drawable: "+sharedDrawable);
System.err.println("!!! Screen : "+sharedScreen);
}
+
+ // don't free native resources from this point on,
+ // since we might be in a critical shutdown hook sequence
+
if(null!=sharedContext) {
- sharedContext.destroy(); // implies release, if current
+ // may cause deadlock: sharedContext.destroy();
sharedContext=null;
}
- // don't free native resources from this point on,
- // since we might be in a critical shutdown hook sequence
if(null!=sharedDrawable) {
// may cause deadlock: sharedDrawable.destroy();
sharedDrawable=null;
@@ -152,7 +160,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
// may cause deadlock: X11Util.closeThreadLocalDisplay(null);
sharedScreen = null;
}
- // don't close pending XDisplay, since they might be a different thread as the opener
+ // don't close pending XDisplay, since this might be a different thread as the opener
X11Util.shutdown( false, DEBUG );
}
@@ -231,13 +239,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
protected NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
- NullWindow nw = null;
- X11Util.XLockDisplay(sharedScreen.getDevice().getHandle());
- try{
- nw = new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capabilities, chooser, sharedScreen));
- }finally{
- X11Util.XUnlockDisplay(sharedScreen.getDevice().getHandle());
- }
+ NullWindow nw = new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capabilities, chooser, sharedScreen));
if(nw != null) {
nw.setSize(width, height);
}
@@ -278,21 +280,16 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
long display = sharedScreen.getDevice().getHandle();
- X11Util.XLockDisplay(display);
- try {
- int[] size = new int[1];
- boolean res = X11Lib.XF86VidModeGetGammaRampSize(display,
- X11Lib.DefaultScreen(display),
- size, 0);
- if (!res) {
- return 0;
- }
- gotGammaRampLength = true;
- gammaRampLength = size[0];
- return gammaRampLength;
- } finally {
- X11Util.XUnlockDisplay(display);
+ int[] size = new int[1];
+ boolean res = X11Lib.XF86VidModeGetGammaRampSize(display,
+ X11Lib.DefaultScreen(display),
+ size, 0);
+ if (!res) {
+ return 0;
}
+ gotGammaRampLength = true;
+ gammaRampLength = size[0];
+ return gammaRampLength;
}
protected boolean setGammaRamp(float[] ramp) {
@@ -303,18 +300,13 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
}
long display = sharedScreen.getDevice().getHandle();
- X11Util.XLockDisplay(display);
- try {
- boolean res = X11Lib.XF86VidModeSetGammaRamp(display,
- X11Lib.DefaultScreen(display),
- rampData.length,
- rampData, 0,
- rampData, 0,
- rampData, 0);
- return res;
- } finally {
- X11Util.XUnlockDisplay(display);
- }
+ boolean res = X11Lib.XF86VidModeSetGammaRamp(display,
+ X11Lib.DefaultScreen(display),
+ rampData.length,
+ rampData, 0,
+ rampData, 0,
+ rampData, 0);
+ return res;
}
protected Buffer getGammaRamp() {
@@ -330,21 +322,16 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
rampData.limit(3 * size);
ShortBuffer blueRampData = rampData.slice();
long display = sharedScreen.getDevice().getHandle();
- X11Util.XLockDisplay(display);
- try {
- boolean res = X11Lib.XF86VidModeGetGammaRamp(display,
- X11Lib.DefaultScreen(display),
- size,
- redRampData,
- greenRampData,
- blueRampData);
- if (!res) {
- return null;
- }
- return rampData;
- } finally {
- X11Util.XUnlockDisplay(display);
+ boolean res = X11Lib.XF86VidModeGetGammaRamp(display,
+ X11Lib.DefaultScreen(display),
+ size,
+ redRampData,
+ greenRampData,
+ blueRampData);
+ if (!res) {
+ return null;
}
+ return rampData;
}
protected void resetGammaRamp(Buffer originalGammaRamp) {
@@ -366,16 +353,11 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
rampData.limit(3 * size);
ShortBuffer blueRampData = rampData.slice();
long display = sharedScreen.getDevice().getHandle();
- X11Util.XLockDisplay(display);
- try {
- X11Lib.XF86VidModeSetGammaRamp(display,
- X11Lib.DefaultScreen(display),
- size,
- redRampData,
- greenRampData,
- blueRampData);
- } finally {
- X11Util.XUnlockDisplay(display);
- }
+ X11Lib.XF86VidModeSetGammaRamp(display,
+ X11Lib.DefaultScreen(display),
+ size,
+ redRampData,
+ greenRampData,
+ blueRampData);
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDynamicLibraryBundleInfo.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDynamicLibraryBundleInfo.java
new file mode 100644
index 000000000..d958996a8
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDynamicLibraryBundleInfo.java
@@ -0,0 +1,88 @@
+/*
+ * 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:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions 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 of Sven Gothel nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Sven Gothel BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.jogamp.opengl.impl.x11.glx;
+
+import com.jogamp.opengl.impl.*;
+import com.jogamp.common.os.DynamicLookupHelper;
+import com.jogamp.common.os.NativeLibrary;
+import com.jogamp.common.os.Platform;
+import java.util.*;
+import java.security.*;
+import javax.media.opengl.GLException;
+
+public class X11GLXDynamicLibraryBundleInfo extends DesktopGLDynamicLibraryBundleInfo {
+ protected X11GLXDynamicLibraryBundleInfo() {
+ super();
+ }
+
+ public List getToolLibNames() {
+ List/*<List>*/ libNamesList = new ArrayList();
+
+ List/*<String>*/ glesLibNames = new ArrayList();
+
+ // Be aware that on DRI systems, eg ATI fglrx, etc,
+ // you have to set LIBGL_DRIVERS_PATH env variable.
+ // Eg on Ubuntu 64bit systems this is:
+ // export LIBGL_DRIVERS_PATH=/usr/lib/fglrx/dri:/usr/lib32/fglrx/dri
+ //
+
+ // this is the default GL lib name, according to the spec
+ glesLibNames.add("libGL.so.1");
+
+ // try this one as well, if spec fails
+ glesLibNames.add("libGL.so");
+
+ // last but not least .. the generic one
+ glesLibNames.add("GL");
+
+ libNamesList.add(glesLibNames);
+
+ return libNamesList;
+ }
+
+ /**
+ * This respects old DRI requirements:<br>
+ * <pre>
+ * http://dri.sourceforge.net/doc/DRIuserguide.html
+ * </pre>
+ */
+ public boolean shallLinkGlobal() { return true; }
+
+ public final List getToolGetProcAddressFuncNameList() {
+ List res = new ArrayList();
+ res.add("glXGetProcAddressARB");
+ res.add("glXGetProcAddress");
+ return res;
+ }
+
+ public final long toolDynamicLookupFunction(long toolGetProcAddressHandle, String funcName) {
+ return GLX.glXGetProcAddress(toolGetProcAddressHandle, funcName);
+ }
+}
+
+
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDynamicLookupHelper.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDynamicLookupHelper.java
deleted file mode 100644
index 867a80bb8..000000000
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDynamicLookupHelper.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions 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 of Sven Gothel nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL Sven Gothel BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.jogamp.opengl.impl.x11.glx;
-
-import com.jogamp.opengl.impl.*;
-import com.jogamp.common.os.DynamicLookupHelper;
-import com.jogamp.common.os.NativeLibrary;
-import com.jogamp.common.os.Platform;
-import java.util.*;
-import java.security.*;
-import javax.media.opengl.GLException;
-
-public class X11GLXDynamicLookupHelper extends DesktopGLDynamicLookupHelper {
- private static final X11GLXDynamicLookupHelper x11GLXDynamicLookupHelper;
-
- static {
- X11GLXDynamicLookupHelper tmp = null;
- try {
- tmp = new X11GLXDynamicLookupHelper();
- } catch (GLException gle) {
- if(DEBUG) {
- gle.printStackTrace();
- }
- }
- x11GLXDynamicLookupHelper = tmp;
- }
-
- public static X11GLXDynamicLookupHelper getX11GLXDynamicLookupHelper() {
- return x11GLXDynamicLookupHelper;
- }
-
- protected X11GLXDynamicLookupHelper() {
- super();
- GLX.getGLXProcAddressTable().reset(this);
- }
-
- public synchronized void loadGLULibrary() {
- if(null==gluLib) {
- List/*<String>*/ gluLibNames = new ArrayList();
- gluLibNames.add("libGLU.so");
- if(Platform.is32Bit()) {
- gluLibNames.add("/usr/lib32/libGLU.so");
- } else {
- gluLibNames.add("/usr/lib64/libGLU.so");
- }
- gluLibNames.add("GLU");
- gluLib = loadFirstAvailable(gluLibNames, null, true);
- if(null != gluLib) {
- glLibraries.add(gluLib);
- }
- }
- }
- NativeLibrary gluLib = null;
-
- protected final List/*<String>*/ getGLLibNames() {
- List/*<String>*/ glesLibNames = new ArrayList();
-
- // first reassemble old DRIHack order, ie using hardcoded names ..
- glesLibNames.add("libGL.so.1");
- if(Platform.is32Bit()) {
- glesLibNames.add("/usr/lib32/libGL.so.1");
- } else {
- glesLibNames.add("/usr/lib64/libGL.so.1");
- }
-
- // at last .. the generic one, should be default!
- glesLibNames.add("GL");
- return glesLibNames;
- }
-
- protected final List/*<String>*/ getGLXLibNames() {
- return null;
- }
-
- protected boolean shallGLLibLoadedGlobal() { return true; }
-
- protected boolean shallGLXLibLoadedGlobal() { return true; }
-
- protected final String getGLXGetProcAddressFuncName() {
- return "glXGetProcAddressARB" ;
- }
-
- protected long dynamicLookupFunctionOnGLX(long glxGetProcAddressHandle, String glFuncName) {
- return GLX.glXGetProcAddressARB(glFuncName);
- }
-}
-
-
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 35daf0ae0..589d7b2db 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
@@ -73,7 +73,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
if(null==caps) {
throw new GLException("GLCapabilities null of "+toHexString(fbcfg));
}
- XVisualInfo xvi = GLX.glXGetVisualFromFBConfigCopied(display, fbcfg);
+ XVisualInfo xvi = GLX.glXGetVisualFromFBConfig(display, fbcfg);
if(null==xvi) {
throw new GLException("XVisualInfo null of "+toHexString(fbcfg));
}
@@ -326,7 +326,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
public static long glXFBConfigID2FBConfig(long display, int screen, int id) {
int[] attribs = new int[] { GLX.GLX_FBCONFIG_ID, id, 0 };
int[] count = { -1 };
- PointerBuffer fbcfgsL = GLX.glXChooseFBConfigCopied(display, screen, attribs, 0, count, 0);
+ PointerBuffer fbcfgsL = GLX.glXChooseFBConfig(display, screen, attribs, 0, count, 0);
if (fbcfgsL == null || fbcfgsL.limit()<1) {
return 0;
}
@@ -336,20 +336,14 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
// Visual Info
public static XVisualInfo XVisualID2XVisualInfo(long display, long visualID) {
- XVisualInfo res = null;
- NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
- try{
- int[] count = new int[1];
- XVisualInfo template = XVisualInfo.create();
- template.setVisualid(visualID);
- XVisualInfo[] infos = X11Lib.XGetVisualInfoCopied(display, X11Lib.VisualIDMask, template, count, 0);
- if (infos == null || infos.length == 0) {
+ int[] count = new int[1];
+ XVisualInfo template = XVisualInfo.create();
+ template.setVisualid(visualID);
+ XVisualInfo[] infos = X11Lib.XGetVisualInfo(display, X11Lib.VisualIDMask, template, count, 0);
+ if (infos == null || infos.length == 0) {
return null;
- }
- res = XVisualInfo.create(infos[0]);
- } finally {
- NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
- }
+ }
+ XVisualInfo res = XVisualInfo.create(infos[0]);
if (DEBUG) {
System.err.println("!!! Fetched XVisualInfo for visual ID " + toHexString(visualID));
System.err.println("!!! Resulting XVisualInfo: visualid = " + toHexString(res.getVisualid()));
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 a160734d3..5c04a29fe 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
@@ -80,8 +80,6 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
GLCapabilities capsFB = null;
long display = x11Screen.getDevice().getHandle();
- NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
- X11Util.XLockDisplay(display);
try {
int screen = x11Screen.getIndex();
boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
@@ -92,7 +90,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(caps, true, isMultisampleAvailable, display, screen);
int[] count = { -1 };
- PointerBuffer fbcfgsL = GLX.glXChooseFBConfigCopied(display, screen, attribs, 0, count, 0);
+ PointerBuffer fbcfgsL = GLX.glXChooseFBConfig(display, screen, attribs, 0, count, 0);
if (fbcfgsL == null || fbcfgsL.limit()<1) {
throw new Exception("Could not fetch FBConfig for "+caps);
}
@@ -101,14 +99,11 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
fbid = X11GLXGraphicsConfiguration.glXFBConfig2FBConfigID(display, fbcfg);
- xvis = GLX.glXGetVisualFromFBConfigCopied(display, fbcfg);
+ xvis = GLX.glXGetVisualFromFBConfig(display, fbcfg);
if (xvis==null) {
throw new GLException("Error: Choosen FBConfig has no visual");
}
} catch (Throwable t) {
- } finally {
- X11Util.XUnlockDisplay(display);
- NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
return new X11GLXGraphicsConfiguration(x11Screen, (null!=capsFB)?capsFB:caps, caps, null, xvis, fbcfg, fbid);
@@ -189,113 +184,103 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
AbstractGraphicsDevice absDevice = x11Screen.getDevice();
long display = absDevice.getHandle();
- NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
- try {
- X11Util.XLockDisplay(display);
- try{
- int screen = x11Screen.getIndex();
- boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
- int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, true, isMultisampleAvailable, display, screen);
- int[] count = { -1 };
-
- // determine the recommended FBConfig ..
- fbcfgsL = GLX.glXChooseFBConfigCopied(display, screen, attribs, 0, count, 0);
- if (fbcfgsL == null || fbcfgsL.limit()<1) {
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXChooseFBConfig ("+x11Screen+","+capabilities+"): "+fbcfgsL+", "+count[0]);
- }
- } else if( !X11GLXGraphicsConfiguration.GLXFBConfigValid( display, fbcfgsL.get(0) ) ) {
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed - GLX FBConfig invalid: ("+x11Screen+","+capabilities+"): "+fbcfgsL+", fbcfg: "+toHexString(fbcfgsL.get(0)));
- }
- } else {
- recommendedFBConfig = fbcfgsL.get(0);
- }
-
- // get all, glXChooseFBConfig(.. attribs==null ..) == glXGetFBConfig(..)
- fbcfgsL = GLX.glXChooseFBConfigCopied(display, screen, null, 0, count, 0);
- if (fbcfgsL == null || fbcfgsL.limit()<1) {
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXGetFBConfig ("+x11Screen+"): "+fbcfgsL+", "+count[0]);
- }
- return null;
- }
+ int screen = x11Screen.getIndex();
+ boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
+ int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, true, isMultisampleAvailable, display, screen);
+ int[] count = { -1 };
- // make GLCapabilities and seek the recommendedIndex
- caps = new GLCapabilities[fbcfgsL.limit()];
- for (int i = 0; i < fbcfgsL.limit(); i++) {
- if( !X11GLXGraphicsConfiguration.GLXFBConfigValid( display, fbcfgsL.get(i) ) ) {
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: FBConfig invalid: ("+x11Screen+","+capabilities+"): fbcfg: "+toHexString(fbcfgsL.get(i)));
- }
- } else {
- caps[i] = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glProfile, display, fbcfgsL.get(i),
- false, onscreen, usePBuffer, isMultisampleAvailable);
- if(caps[i]!=null && recommendedFBConfig==fbcfgsL.get(i)) {
- recommendedIndex=i;
- if (DEBUG) {
- System.err.println("!!! glXChooseFBConfig recommended "+i+", "+caps[i]);
- }
- }
- }
- }
+ // determine the recommended FBConfig ..
+ fbcfgsL = GLX.glXChooseFBConfig(display, screen, attribs, 0, count, 0);
+ if (fbcfgsL == null || fbcfgsL.limit()<1) {
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXChooseFBConfig ("+x11Screen+","+capabilities+"): "+fbcfgsL+", "+count[0]);
+ }
+ } else if( !X11GLXGraphicsConfiguration.GLXFBConfigValid( display, fbcfgsL.get(0) ) ) {
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed - GLX FBConfig invalid: ("+x11Screen+","+capabilities+"): "+fbcfgsL+", fbcfg: "+toHexString(fbcfgsL.get(0)));
+ }
+ } else {
+ recommendedFBConfig = fbcfgsL.get(0);
+ }
- if(null==chooser) {
- chosen = recommendedIndex; // may still be -1 in case nothing was recommended (-1)
- }
+ // get all, glXChooseFBConfig(.. attribs==null ..) == glXGetFBConfig(..)
+ fbcfgsL = GLX.glXChooseFBConfig(display, screen, null, 0, count, 0);
+ if (fbcfgsL == null || fbcfgsL.limit()<1) {
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXGetFBConfig ("+x11Screen+"): "+fbcfgsL+", "+count[0]);
+ }
+ return null;
+ }
- if (chosen < 0) {
- if(null==chooser) {
- // nothing recommended .. so use our default implementation
- chooser = new DefaultGLCapabilitiesChooser();
- }
- try {
- chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
- } catch (NativeWindowException e) {
- if(DEBUG) {
- e.printStackTrace();
- }
- chosen = -1;
- }
+ // make GLCapabilities and seek the recommendedIndex
+ caps = new GLCapabilities[fbcfgsL.limit()];
+ for (int i = 0; i < fbcfgsL.limit(); i++) {
+ if( !X11GLXGraphicsConfiguration.GLXFBConfigValid( display, fbcfgsL.get(i) ) ) {
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: FBConfig invalid: ("+x11Screen+","+capabilities+"): fbcfg: "+toHexString(fbcfgsL.get(i)));
}
- if (chosen < 0) {
- // keep on going ..
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig Failed .. unable to choose config, using first");
- }
- // seek first available one ..
- for(chosen = 0; chosen < caps.length && caps[chosen]==null; chosen++) ;
- if(chosen==caps.length) {
- // give up ..
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig Failed .. nothing available, bail out");
- }
- return null;
- }
- } else if (chosen >= caps.length) {
- if(DEBUG) {
- System.err.println("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ", got "+chosen+")");
+ } else {
+ caps[i] = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glProfile, display, fbcfgsL.get(i),
+ false, onscreen, usePBuffer, isMultisampleAvailable);
+ if(caps[i]!=null && recommendedFBConfig==fbcfgsL.get(i)) {
+ recommendedIndex=i;
+ if (DEBUG) {
+ System.err.println("!!! glXChooseFBConfig recommended "+i+", "+caps[i]);
}
- return null;
}
+ }
+ }
- retFBID = X11GLXGraphicsConfiguration.glXFBConfig2FBConfigID(display, fbcfgsL.get(chosen));
+ if(null==chooser) {
+ chosen = recommendedIndex; // may still be -1 in case nothing was recommended (-1)
+ }
- retXVisualInfo = GLX.glXGetVisualFromFBConfigCopied(display, fbcfgsL.get(chosen));
- if (retXVisualInfo==null) {
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXGetVisualFromFBConfig ("+x11Screen+", "+fbcfgsL.get(chosen) +" (Continue: "+(false==caps[chosen].isOnscreen())+"):\n\t"+caps[chosen]);
- }
- if(caps[chosen].isOnscreen()) {
- // Onscreen drawables shall have a XVisual ..
- return null;
- }
- }
- }finally{
- X11Util.XUnlockDisplay(display);
+ if (chosen < 0) {
+ if(null==chooser) {
+ // nothing recommended .. so use our default implementation
+ chooser = new DefaultGLCapabilitiesChooser();
+ }
+ try {
+ chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
+ } catch (NativeWindowException e) {
+ if(DEBUG) {
+ e.printStackTrace();
+ }
+ chosen = -1;
+ }
+ }
+ if (chosen < 0) {
+ // keep on going ..
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig Failed .. unable to choose config, using first");
+ }
+ // seek first available one ..
+ for(chosen = 0; chosen < caps.length && caps[chosen]==null; chosen++) ;
+ if(chosen==caps.length) {
+ // give up ..
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig Failed .. nothing available, bail out");
+ }
+ return null;
+ }
+ } else if (chosen >= caps.length) {
+ if(DEBUG) {
+ System.err.println("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ", got "+chosen+")");
+ }
+ return null;
+ }
+
+ retFBID = X11GLXGraphicsConfiguration.glXFBConfig2FBConfigID(display, fbcfgsL.get(chosen));
+
+ retXVisualInfo = GLX.glXGetVisualFromFBConfig(display, fbcfgsL.get(chosen));
+ if (retXVisualInfo==null) {
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXGetVisualFromFBConfig ("+x11Screen+", "+fbcfgsL.get(chosen) +" (Continue: "+(false==caps[chosen].isOnscreen())+"):\n\t"+caps[chosen]);
+ }
+ if(caps[chosen].isOnscreen()) {
+ // Onscreen drawables shall have a XVisual ..
+ return null;
}
- } finally {
- NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
return new X11GLXGraphicsConfiguration(x11Screen, caps[chosen], capabilities, chooser, retXVisualInfo, fbcfgsL.get(chosen), retFBID);
@@ -322,66 +307,56 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
AbstractGraphicsDevice absDevice = x11Screen.getDevice();
long display = absDevice.getHandle();
- NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
- try {
- X11Util.XLockDisplay(display);
- try{
- int screen = x11Screen.getIndex();
- boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
- int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, false, isMultisampleAvailable, display, screen);
- XVisualInfo[] infos = null;
-
- XVisualInfo recommendedVis = GLX.glXChooseVisualCopied(display, screen, attribs, 0);
- if (DEBUG) {
- System.err.print("!!! glXChooseVisual recommended ");
- if (recommendedVis == null) {
- System.err.println("null visual");
- } else {
- System.err.println("visual id " + toHexString(recommendedVis.getVisualid()));
- }
- }
- int[] count = new int[1];
- XVisualInfo template = XVisualInfo.create();
- template.setScreen(screen);
- infos = X11Lib.XGetVisualInfoCopied(display, X11Lib.VisualScreenMask, template, count, 0);
- if (infos == null || infos.length<1) {
- throw new GLException("Error while enumerating available XVisualInfos");
- }
- caps = new GLCapabilities[infos.length];
- for (int i = 0; i < infos.length; i++) {
- caps[i] = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(glProfile, display, infos[i], onscreen, false, isMultisampleAvailable);
- // Attempt to find the visual chosen by glXChooseVisual
- if (recommendedVis != null && recommendedVis.getVisualid() == infos[i].getVisualid()) {
- recommendedIndex = i;
- }
- }
- try {
- chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
- } catch (NativeWindowException e) {
- if(DEBUG) {
- e.printStackTrace();
- }
- chosen = -1;
- }
- if (chosen < 0) {
- // keep on going ..
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationXVisual Failed .. unable to choose config, using first");
- }
- chosen = 0; // default ..
- } else if (chosen >= caps.length) {
- throw new GLException("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ")");
- }
- if (infos[chosen] == null) {
- throw new GLException("GLCapabilitiesChooser chose an invalid visual for "+caps[chosen]);
- }
- retXVisualInfo = XVisualInfo.create(infos[chosen]);
- }finally{
- X11Util.XUnlockDisplay(display);
+ int screen = x11Screen.getIndex();
+ boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
+ int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, false, isMultisampleAvailable, display, screen);
+ XVisualInfo[] infos = null;
+
+ XVisualInfo recommendedVis = GLX.glXChooseVisual(display, screen, attribs, 0);
+ if (DEBUG) {
+ System.err.print("!!! glXChooseVisual recommended ");
+ if (recommendedVis == null) {
+ System.err.println("null visual");
+ } else {
+ System.err.println("visual id " + toHexString(recommendedVis.getVisualid()));
+ }
+ }
+ int[] count = new int[1];
+ XVisualInfo template = XVisualInfo.create();
+ template.setScreen(screen);
+ infos = X11Lib.XGetVisualInfo(display, X11Lib.VisualScreenMask, template, count, 0);
+ if (infos == null || infos.length<1) {
+ throw new GLException("Error while enumerating available XVisualInfos");
+ }
+ caps = new GLCapabilities[infos.length];
+ for (int i = 0; i < infos.length; i++) {
+ caps[i] = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(glProfile, display, infos[i], onscreen, false, isMultisampleAvailable);
+ // Attempt to find the visual chosen by glXChooseVisual
+ if (recommendedVis != null && recommendedVis.getVisualid() == infos[i].getVisualid()) {
+ recommendedIndex = i;
}
- } finally {
- NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
+ try {
+ chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
+ } catch (NativeWindowException e) {
+ if(DEBUG) {
+ e.printStackTrace();
+ }
+ chosen = -1;
+ }
+ if (chosen < 0) {
+ // keep on going ..
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationXVisual Failed .. unable to choose config, using first");
+ }
+ chosen = 0; // default ..
+ } else if (chosen >= caps.length) {
+ throw new GLException("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ")");
+ }
+ if (infos[chosen] == null) {
+ throw new GLException("GLCapabilitiesChooser chose an invalid visual for "+caps[chosen]);
+ }
+ retXVisualInfo = XVisualInfo.create(infos[chosen]);
return new X11GLXGraphicsConfiguration(x11Screen, caps[chosen], capabilities, chooser, retXVisualInfo, 0, -1);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java
index bea953ee9..5482d5566 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java
@@ -71,7 +71,7 @@ public class X11OffscreenGLXContext extends X11GLXContext {
return true;
}
- protected void create() {
- createContext(false);
+ protected boolean createImpl() {
+ return createContext(false);
}
}
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 5771e9c42..230387c1c 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
@@ -73,33 +73,22 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
long dpy = aDevice.getHandle();
int screen = aScreen.getIndex();
- getFactoryImpl().lockToolkit();
- try {
- X11Util.XLockDisplay(dpy);
- try{
-
- pixmap = X11Lib.XCreatePixmap(dpy, X11Lib.RootWindow(dpy, screen),
- component.getWidth(), component.getHeight(), bitsPerPixel);
- if (pixmap == 0) {
- throw new GLException("XCreatePixmap failed");
- }
- long drawable = GLX.glXCreateGLXPixmap(dpy, vis, pixmap);
- if (drawable == 0) {
- X11Lib.XFreePixmap(dpy, pixmap);
- pixmap = 0;
- throw new GLException("glXCreateGLXPixmap failed");
- }
- ((SurfaceChangeable)nw).setSurfaceHandle(drawable);
- if (DEBUG) {
- System.err.println("Created pixmap " + toHexString(pixmap) +
- ", GLXPixmap " + toHexString(drawable) +
- ", display " + toHexString(dpy));
- }
- }finally{
- X11Util.XUnlockDisplay(dpy);
- }
- } finally {
- getFactoryImpl().unlockToolkit();
+ pixmap = X11Lib.XCreatePixmap(dpy, X11Lib.RootWindow(dpy, screen),
+ component.getWidth(), component.getHeight(), bitsPerPixel);
+ if (pixmap == 0) {
+ throw new GLException("XCreatePixmap failed");
+ }
+ long drawable = GLX.glXCreateGLXPixmap(dpy, vis, pixmap);
+ if (drawable == 0) {
+ X11Lib.XFreePixmap(dpy, pixmap);
+ pixmap = 0;
+ throw new GLException("glXCreateGLXPixmap failed");
+ }
+ ((SurfaceChangeable)nw).setSurfaceHandle(drawable);
+ if (DEBUG) {
+ System.err.println("Created pixmap " + toHexString(pixmap) +
+ ", GLXPixmap " + toHexString(drawable) +
+ ", display " + toHexString(dpy));
}
}
@@ -109,46 +98,36 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
NativeWindow nw = getNativeWindow();
long display = nw.getDisplayHandle();
- getFactoryImpl().lockToolkit();
- try {
- X11Util.XLockDisplay(display);
- try{
- long drawable = nw.getSurfaceHandle();
- if (DEBUG) {
- System.err.println("Destroying pixmap " + toHexString(pixmap) +
- ", GLXPixmap " + toHexString(drawable) +
- ", display " + toHexString(display));
- }
-
- // Must destroy pixmap and GLXPixmap
-
- if (DEBUG) {
- long cur = GLX.glXGetCurrentContext();
- if (cur != 0) {
- System.err.println("WARNING: found context " + toHexString(cur) + " current during pixmap destruction");
- }
- }
-
- // FIXME: workaround for crashes on NVidia hardware when
- // destroying pixmap (no context is current at the point of the
- // crash, at least from the point of view of
- // glXGetCurrentContext)
- GLX.glXMakeCurrent(display, 0, 0);
+ long drawable = nw.getSurfaceHandle();
+ if (DEBUG) {
+ System.err.println("Destroying pixmap " + toHexString(pixmap) +
+ ", GLXPixmap " + toHexString(drawable) +
+ ", display " + toHexString(display));
+ }
- GLX.glXDestroyGLXPixmap(display, drawable);
- X11Lib.XFreePixmap(display, pixmap);
- drawable = 0;
- pixmap = 0;
- ((SurfaceChangeable)nw).setSurfaceHandle(0);
+ // Must destroy pixmap and GLXPixmap
- }finally{
- X11Util.XUnlockDisplay(display);
+ if (DEBUG) {
+ long cur = GLX.glXGetCurrentContext();
+ if (cur != 0) {
+ System.err.println("WARNING: found context " + toHexString(cur) + " current during pixmap destruction");
}
- } finally {
- getFactoryImpl().unlockToolkit();
- display = 0;
}
+
+ // FIXME: workaround for crashes on NVidia hardware when
+ // destroying pixmap (no context is current at the point of the
+ // crash, at least from the point of view of
+ // glXGetCurrentContext)
+ GLX.glXMakeCurrent(display, 0, 0);
+
+ GLX.glXDestroyGLXPixmap(display, drawable);
+ X11Lib.XFreePixmap(display, pixmap);
+ drawable = 0;
+ pixmap = 0;
+ ((SurfaceChangeable)nw).setSurfaceHandle(0);
+ display = 0;
}
+
protected void swapBuffersImpl() {
if(DEBUG) {
System.err.println("unhandled swapBuffersImpl() called for: "+this);
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXContext.java
index 710f93e98..bb1e2fd4c 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXContext.java
@@ -47,22 +47,12 @@ import com.jogamp.opengl.impl.*;
import com.jogamp.opengl.impl.x11.*;
public class X11OnscreenGLXContext extends X11GLXContext {
- // This indicates whether the context we have created is indirect
- // and therefore requires the toolkit to be locked around all GL
- // calls rather than just all GLX calls
- protected boolean isIndirect;
-
public X11OnscreenGLXContext(X11OnscreenGLXDrawable drawable,
GLContext shareWith) {
super(drawable, shareWith);
}
- public boolean isOptimizable() {
- return super.isOptimizable() && !isIndirect;
- }
-
- protected void create() {
- createContext(true);
- isIndirect = !GLX.glXIsDirect(drawable.getNativeWindow().getDisplayHandle(), contextHandle);
+ protected boolean createImpl() {
+ return createContext(true);
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java
index 43468b858..a9aafa5af 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java
@@ -43,10 +43,54 @@ import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.jogamp.opengl.impl.*;
import com.jogamp.opengl.impl.x11.*;
+import com.jogamp.nativewindow.impl.x11.*;
public class X11OnscreenGLXDrawable extends X11GLXDrawable {
+ /** GLXWindow can't be made current on AWT with NVidia driver, hence disabled for now */
+ public static final boolean USE_GLXWINDOW = false;
+ long glXWindow; // GLXWindow, a GLXDrawable representation
+ boolean useGLXWindow;
+
protected X11OnscreenGLXDrawable(GLDrawableFactory factory, NativeWindow component) {
super(factory, component, false);
+ glXWindow=0;
+ useGLXWindow=false;
+ }
+
+ public long getHandle() {
+ if(useGLXWindow) {
+ return glXWindow;
+ }
+ return getNativeWindow().getSurfaceHandle();
+ }
+
+ protected void destroyHandle() {
+ if(0!=glXWindow) {
+ GLX.glXDestroyWindow(getNativeWindow().getDisplayHandle(), glXWindow);
+ glXWindow = 0;
+ useGLXWindow=false;
+ }
+ }
+
+ /** must be locked already */
+ protected void updateHandle() {
+ if(USE_GLXWINDOW) {
+ X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ if(config.getFBConfig()>=0) {
+ useGLXWindow=true;
+ long dpy = getNativeWindow().getDisplayHandle();
+ if(0!=glXWindow) {
+ GLX.glXDestroyWindow(dpy, glXWindow);
+ }
+ glXWindow = GLX.glXCreateWindow(dpy, config.getFBConfig(), getNativeWindow().getSurfaceHandle(), null, 0);
+ if (DEBUG) {
+ System.err.println("!!! X11OnscreenGLXDrawable.setRealized(true): glXWindow: "+toHexString(getNativeWindow().getSurfaceHandle())+" -> "+toHexString(glXWindow));
+ }
+ if(0==glXWindow) {
+ throw new GLException("X11OnscreenGLXDrawable.setRealized(true): GLX.glXCreateWindow() failed: "+this);
+ }
+ }
+ }
}
public GLContext createContext(GLContext shareWith) {
@@ -60,5 +104,4 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable {
public int getHeight() {
return component.getHeight();
}
-
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXContext.java
index 1b70adf6b..debf28127 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXContext.java
@@ -67,7 +67,7 @@ public class X11PbufferGLXContext extends X11GLXContext {
return drawable.getFloatingPointMode();
}
- protected void create() {
- createContext(true);
+ protected boolean createImpl() {
+ return createContext(true);
}
}
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 50b32b9ec..009fa147f 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
@@ -76,21 +76,14 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
}
public void destroy() {
- getFactoryImpl().lockToolkit();
- try {
- NativeWindow nw = getNativeWindow();
- if (nw.getSurfaceHandle() != 0) {
- GLX.glXDestroyPbuffer(nw.getDisplayHandle(), nw.getSurfaceHandle());
- }
- ((SurfaceChangeable)nw).setSurfaceHandle(0);
- } finally {
- getFactoryImpl().unlockToolkit();
+ NativeWindow nw = getNativeWindow();
+ if (nw.getSurfaceHandle() != 0) {
+ GLX.glXDestroyPbuffer(nw.getDisplayHandle(), nw.getSurfaceHandle());
}
+ ((SurfaceChangeable)nw).setSurfaceHandle(0);
}
private void createPbuffer() {
- getFactoryImpl().lockToolkit();
- try {
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
AbstractGraphicsScreen aScreen = config.getScreen();
AbstractGraphicsDevice aDevice = aScreen.getDevice();
@@ -139,9 +132,6 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
GLX.glXQueryDrawable(display, pbuffer, GLX.GLX_HEIGHT, tmp, 0);
int height = tmp[0];
((SurfaceChangeable)nw).setSize(width, height);
- } finally {
- getFactoryImpl().unlockToolkit();
- }
}
public int getFloatingPointMode() {
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 dc6c60664..9e52040cf 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
@@ -87,57 +87,51 @@ public class X11AWTGLXGraphicsConfigurationFactory extends GraphicsConfiguration
GraphicsConfiguration gc;
X11GraphicsConfiguration x11Config;
- // Need the lock here, since it could be an AWT owned display connection
- NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
- try {
- long displayHandle = X11SunJDKReflection.graphicsDeviceGetDisplay(device);
- if(0==displayHandle) {
- displayHandle = X11Util.createThreadLocalDefaultDisplay();
- if(DEBUG) {
- System.err.println("X11AWTGLXGraphicsConfigurationFactory: using a thread local X11 display");
- }
- } else {
- if(DEBUG) {
- System.err.println("X11AWTGLXGraphicsConfigurationFactory: using AWT X11 display 0x"+Long.toHexString(displayHandle));
- }
- }
- ((AWTGraphicsDevice)awtScreen.getDevice()).setHandle(displayHandle);
- X11GraphicsDevice x11Device = new X11GraphicsDevice(displayHandle);
-
- X11GraphicsScreen x11Screen = new X11GraphicsScreen(x11Device, awtScreen.getIndex());
+ long displayHandle = X11SunJDKReflection.graphicsDeviceGetDisplay(device);
+ if(0==displayHandle) {
+ displayHandle = X11Util.createThreadLocalDisplay(null);
if(DEBUG) {
- System.err.println("X11AWTGLXGraphicsConfigurationFactory: made "+x11Screen);
+ System.err.println("X11AWTGLXGraphicsConfigurationFactory: using a thread local X11 display");
}
-
- gc = device.getDefaultConfiguration();
- AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capabilities, gc);
+ } else {
if(DEBUG) {
- System.err.println("AWT Colormodel compatible: "+capabilities);
+ System.err.println("X11AWTGLXGraphicsConfigurationFactory: using AWT X11 display 0x"+Long.toHexString(displayHandle));
}
+ }
+ ((AWTGraphicsDevice)awtScreen.getDevice()).setHandle(displayHandle);
+ X11GraphicsDevice x11Device = new X11GraphicsDevice(displayHandle);
- x11Config = (X11GraphicsConfiguration)
- GraphicsConfigurationFactory.getFactory(x11Device).chooseGraphicsConfiguration(capabilities,
- chooser,
- x11Screen);
- if (x11Config == null) {
- throw new GLException("Unable to choose a GraphicsConfiguration: "+capabilities+",\n\t"+chooser+"\n\t"+x11Screen);
- }
+ X11GraphicsScreen x11Screen = new X11GraphicsScreen(x11Device, awtScreen.getIndex());
+ if(DEBUG) {
+ System.err.println("X11AWTGLXGraphicsConfigurationFactory: made "+x11Screen);
+ }
+
+ gc = device.getDefaultConfiguration();
+ AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capabilities, gc);
+ if(DEBUG) {
+ System.err.println("AWT Colormodel compatible: "+capabilities);
+ }
+
+ x11Config = (X11GraphicsConfiguration)
+ GraphicsConfigurationFactory.getFactory(x11Device).chooseGraphicsConfiguration(capabilities,
+ chooser,
+ x11Screen);
+ if (x11Config == null) {
+ throw new GLException("Unable to choose a GraphicsConfiguration: "+capabilities+",\n\t"+chooser+"\n\t"+x11Screen);
+ }
- long visualID = x11Config.getVisualID();
- // Now figure out which GraphicsConfiguration corresponds to this
- // visual by matching the visual ID
- GraphicsConfiguration[] configs = device.getConfigurations();
- for (int i = 0; i < configs.length; i++) {
- GraphicsConfiguration config = configs[i];
- if (config != null) {
- if (X11SunJDKReflection.graphicsConfigurationGetVisualID(config) == visualID) {
- return new AWTGraphicsConfiguration(awtScreen, x11Config.getChosenCapabilities(), x11Config.getRequestedCapabilities(),
- config, x11Config);
- }
+ long visualID = x11Config.getVisualID();
+ // Now figure out which GraphicsConfiguration corresponds to this
+ // visual by matching the visual ID
+ GraphicsConfiguration[] configs = device.getConfigurations();
+ for (int i = 0; i < configs.length; i++) {
+ GraphicsConfiguration config = configs[i];
+ if (config != null) {
+ if (X11SunJDKReflection.graphicsConfigurationGetVisualID(config) == visualID) {
+ return new AWTGraphicsConfiguration(awtScreen, x11Config.getChosenCapabilities(), x11Config.getRequestedCapabilities(),
+ config, x11Config);
}
}
- } finally {
- NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
// Either we weren't able to reflectively introspect on the
// X11GraphicsConfig or something went wrong in the steps above;