aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/impl/x11/glx
diff options
context:
space:
mode:
authorSven Gothel <sgothel@jausoft.com>2010-06-04 05:21:32 +0200
committerSven Gothel <sgothel@jausoft.com>2010-06-04 05:21:32 +0200
commit4512900ddcb9ce9a498411d257b1b6d6010ec006 (patch)
treeae9878c82cda41920f46ea639178f7d951d5af8f /src/jogl/classes/com/jogamp/opengl/impl/x11/glx
parent6bbf70d2f4a06b8aa0b100d83ed9aca6dd80040e (diff)
JOGL: Unify library loading (impl and binding), incl. lookup ; GLAutoDrawable: dispose() calls only with created context.
- Using the EGL approach of DynamicLookupHelper, now generalized in abstract GLDynamicLookupHelper, DesktopGLDynamicLookupHelper and EGLGLDynamicLookupHelper. The implementation of these are self contained. - Sharing common code. - Unifying implementation and binding loading, as well as the function lookup within the impl libs. - Removed DRIHack, since its no more required due to the new DesktopGLDynamicLookupHelper. - Removed compile time link to GL and GLU libs - Removed redundant library OS functions from X11/WGL bindings, GlueGen's common code is being used now. - GLAutoDrawable: dispose() calls only with created context. This cleans up stack traces in case of eventual bugs, where context creation is not successful.
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/impl/x11/glx')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java12
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawable.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java25
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDynamicLookupHelper.java113
4 files changed, 127 insertions, 27 deletions
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 b81521729..baca6bfa4 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
@@ -192,9 +192,6 @@ public abstract class X11GLXContext extends GLContextImpl {
re.printStackTrace();
}
}
- if(DEBUG) {
- System.err.println("X11GLXContext.createContextARB success: "+(0!=ctx)+" - "+getGLVersion(major, minor, ctp, "@creation")+", bwdCompat "+ctBwdCompat+", fwdCompat "+ctFwdCompat);
- }
if(0!=ctx) {
if (!glXMakeContextCurrent(display,
drawable.getNativeWindow().getSurfaceHandle(),
@@ -288,13 +285,16 @@ public abstract class X11GLXContext extends GLContextImpl {
setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY); // use GL_VERSION
if( createContextARBTried ||
- !isFunctionAvailable("glXCreateContextAttribsARB") ||
- !isExtensionAvailable("GLX_ARB_create_context") ) {
+ !isFunctionAvailable("glXCreateContextAttribsARB") /* ||
+ !isExtensionAvailable("GLX_ARB_create_context") */ ) { // unresolved case where client version is 1.4 without this extension
if(glp.isGL3()) {
glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_ctx);
throw new GLException("Unable to create OpenGL >= 3.1 context (failed GLX_ARB_create_context), GLProfile "+glp+", Drawable "+drawable);
}
+ if(DEBUG) {
+ System.err.println("X11GLXContext.createContext: createContextARBTried "+createContextARBTried+", hasFunc glXCreateContextAttribsARB: "+isFunctionAvailable("glXCreateContextAttribsARB")+", hasExt GLX_ARB_create_context: "+isExtensionAvailable("GLX_ARB_create_context"));
+ }
// continue with temp context for GL < 3.0
contextHandle = temp_ctx;
@@ -488,7 +488,7 @@ public abstract class X11GLXContext extends GLContextImpl {
public synchronized String getPlatformExtensionsString() {
if (!glXQueryExtensionsStringInitialized) {
glXQueryExtensionsStringAvailable =
- getDrawableImpl().getDynamicLookupHelper().dynamicLookupFunction("glXQueryExtensionsString") != 0;
+ getDrawableImpl().getGLDynamicLookupHelper().dynamicLookupFunction("glXQueryExtensionsString") != 0;
glXQueryExtensionsStringInitialized = true;
}
if (glXQueryExtensionsStringAvailable) {
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 95dfc0a1c..e943abc43 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
@@ -49,8 +49,8 @@ public abstract class X11GLXDrawable extends GLDrawableImpl {
super(factory, comp, realized);
}
- public DynamicLookupHelper getDynamicLookupHelper() {
- return (X11GLXDrawableFactory) getFactoryImpl() ;
+ public GLDynamicLookupHelper getGLDynamicLookupHelper() {
+ return X11GLXDynamicLookupHelper.getX11GLXDynamicLookupHelper();
}
protected void setRealizedImpl() {
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 e2b24f9f0..fe2176f61 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
@@ -36,7 +36,6 @@
package com.jogamp.opengl.impl.x11.glx;
-import com.jogamp.common.os.DynamicLookupHelper;
import java.nio.*;
import javax.media.nativewindow.*;
import javax.media.nativewindow.x11.*;
@@ -48,17 +47,19 @@ import com.jogamp.common.util.*;
import com.jogamp.nativewindow.impl.NullWindow;
import com.jogamp.nativewindow.impl.x11.*;
-public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements DynamicLookupHelper {
+public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
static {
X11Util.initSingleton(); // ensure it's loaded and setup
}
+ public GLDynamicLookupHelper getGLDynamicLookupHelper(int profile) {
+ return X11GLXDynamicLookupHelper.getX11GLXDynamicLookupHelper();
+ }
+
public X11GLXDrawableFactory() {
super();
- // Must initialize GLX support eagerly in case a pbuffer is the
- // first thing instantiated
- GLX.getGLXProcAddressTable().reset(this);
+ X11GLXDynamicLookupHelper.getX11GLXDynamicLookupHelper(); // ensure it's loaded and setup
// Register our GraphicsConfigurationFactory implementations
// The act of constructing them causes them to be registered
new X11GLXGraphicsConfigurationFactory();
@@ -255,20 +256,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
return X11ExternalGLXDrawable.create(this, null);
}
- public void loadGLULibrary() {
- X11Lib.dlopen("/usr/lib/libGLU.so");
- }
-
- public long dynamicLookupFunction(String glFuncName) {
- long res = 0;
- res = GLX.glXGetProcAddressARB(glFuncName);
- if (res == 0) {
- // GLU routines aren't known to the OpenGL function lookup
- res = X11Lib.dlsym(glFuncName);
- }
- return res;
- }
-
public boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device) {
return false;
}
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
new file mode 100644
index 000000000..867a80bb8
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDynamicLookupHelper.java
@@ -0,0 +1,113 @@
+/*
+ * 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);
+ }
+}
+
+