summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl')
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/DRIHack.java137
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/DesktopGLDynamicLookupHelper.java81
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java15
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java12
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java3
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/GLDynamicLookupHelper.java184
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java2
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java6
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java7
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLDynamicLookupHelper.java222
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLES1DynamicLookupHelper.java77
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLES2DynamicLookupHelper.java77
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java19
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDynamicLookupHelper.java93
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java5
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java53
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDynamicLookupHelper.java91
-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
23 files changed, 747 insertions, 499 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/DRIHack.java b/src/jogl/classes/com/jogamp/opengl/impl/DRIHack.java
deleted file mode 100755
index 7e81d194b..000000000
--- a/src/jogl/classes/com/jogamp/opengl/impl/DRIHack.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2006 Sun Microsystems, Inc. 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 of Sun Microsystems, Inc. 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
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.opengl.impl;
-
-import com.jogamp.common.os.NativeLibrary;
-import com.jogamp.common.os.Platform;
-import java.io.*;
-import java.security.*;
-
-/**
- * Helper class for working around problems with open-source DRI
- * drivers. In the current DRI implementation it is required that the
- * symbols in libGL.so.1.2 be globally visible to be accessible from
- * other libraries that are dynamically loaded by the implementation.
- * Applications may typically satisfy this need either by linking
- * against libGL.so on the command line (-lGL) or by dlopen'ing
- * libGL.so.1.2 with the RTLD_GLOBAL flag. The JOGL implementation
- * links against libGL on all platforms rather than forcing all OpenGL
- * entry points to be called through a function pointer. This allows
- * the JOGL library to link directly to core 1.1 OpenGL entry points
- * like glVertex3f, while calling through function pointers for entry
- * points from later OpenGL versions as well as from
- * extensions. However, because libjogl.so (which links against
- * libGL.so) is loaded by the JVM, and because the JVM implicitly uses
- * RTLD_LOCAL in the implementation of System.loadLibrary(), this
- * means via transitivity that the symbols for libGL.so have only
- * RTLD_LOCAL visibility to the rest of the application, so the DRI
- * drivers can not find the symbols required. <P>
- *
- * There are at least two possible solutions. One would be to change
- * the JOGL implementation to call through function pointers uniformly
- * so that it does not need to link against libGL.so. This is
- * possible, but requires changes to GlueGen and also is not really
- * necessary in any other situation than with the DRI drivers. Another
- * solution is to force the first load of libGL.so.1.2 to be done
- * dynamically with RTLD_GLOBAL before libjogl.so is loaded and causes
- * libGL.so.1.2 to be loaded again. The NativeLibrary class in the
- * GlueGen runtime has this property, and we use it to implement this
- * workaround.
- */
-
-public class DRIHack {
-
- private static final boolean DEBUG = Debug.debug("DRIHack");
- private static boolean driHackNeeded;
- private static NativeLibrary oglLib;
-
- static {
- // Allow manual overriding for now as a workaround for
- // problems seen in some situations -- needs more investigation
- if (Debug.getProperty("jogl.drihack.disable", true) != null) {
- driHackNeeded = false;
- } else {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- String os = Platform.getOS().toLowerCase();
- // Do DRI hack on all Linux distributions for best robustness
- driHackNeeded = os.startsWith("linux")
- || new File("/usr/lib/dri").exists()
- || new File("/usr/X11R6/lib/modules/dri").exists();
- return null;
- }
- });
- }
- }
-
- public static void begin() {
-
- if (driHackNeeded) {
- if (DEBUG) {
- System.err.println("Beginning DRI hack");
- }
-
- // Try a few different variants for best robustness
- // In theory probably only the first is necessary
- oglLib = NativeLibrary.open("libGL.so.1", null);
- if (DEBUG && oglLib != null) {
- System.err.println(" Found libGL.so.1");
- }
- if (oglLib == null) {
- oglLib = NativeLibrary.open("/usr/lib/libGL.so.1", null);
- if (DEBUG && oglLib != null) {
- System.err.println(" Found /usr/lib/libGL.so.1");
- }
- }
- }
-
- }
-
- public static void end() {
- if (oglLib != null) {
- if (DEBUG) {
- System.err.println("Ending DRI hack");
- }
-
- oglLib.close();
- oglLib = null;
- }
- }
-}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/DesktopGLDynamicLookupHelper.java b/src/jogl/classes/com/jogamp/opengl/impl/DesktopGLDynamicLookupHelper.java
new file mode 100755
index 000000000..f9858df62
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/impl/DesktopGLDynamicLookupHelper.java
@@ -0,0 +1,81 @@
+/*
+ * 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;
+
+/**
+ * Abstract implementation of the DynamicLookupHelper for GL,
+ * which decouples it's dependencies to EGLDrawableFactory.
+ *
+ * Currently two implementations exist, one for ES1 and one for ES2.
+ */
+public abstract class DesktopGLDynamicLookupHelper extends GLDynamicLookupHelper {
+ private boolean hasGLBinding = false;
+ private boolean hasGLES12Binding = false;
+
+ public boolean hasGLBinding() { return hasGLBinding; }
+ public boolean hasGLES12Binding() { return hasGLES12Binding; }
+
+ protected void loadGLJNILibrary() {
+ Throwable t=null;
+
+ try {
+ GLJNILibLoader.loadGLDesktop();
+ hasGLBinding = true;
+ } catch (UnsatisfiedLinkError ule) {
+ t=ule;
+ } catch (SecurityException se) {
+ t=se;
+ } catch (NullPointerException npe) {
+ t=npe;
+ } catch (RuntimeException re) {
+ t=re;
+ }
+ if(DEBUG && null!=t) {
+ System.err.println("DesktopGLDynamicLookupHelper: Desktop GL Binding Library not available");
+ t.printStackTrace();
+ }
+
+ try {
+ GLJNILibLoader.loadGLDesktopES12();
+ hasGLES12Binding = true;
+ } catch (UnsatisfiedLinkError ule) {
+ t=ule;
+ } catch (SecurityException se) {
+ t=se;
+ } catch (NullPointerException npe) {
+ t=npe;
+ } catch (RuntimeException re) {
+ t=re;
+ }
+ if(DEBUG && null!=t) {
+ System.err.println("DesktopGLDynamicLookupHelper: Desktop GLES12 Binding Library not available");
+ t.printStackTrace();
+ }
+ }
+}
+
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
index 416f0d694..0742587dd 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
@@ -234,7 +234,7 @@ public abstract class GLContextImpl extends GLContext {
* </ul>
* </ul><br>
*
- * Once at startup, ie triggered by the singleton {@link GLDrawableImpl} constructor,
+ * Once at startup, ie triggered by the singleton constructor of a {@link GLDrawableFactoryImpl} specialization,
* calling {@link #createContextARB} will query all available OpenGL versions:<br>
* <ul>
* <li> <code>FOR ALL GL* DO</code>:
@@ -396,6 +396,9 @@ public abstract class GLContextImpl extends GLContext {
GLProfile glp = glCaps.getGLProfile();
long _context = 0;
+ if (DEBUG) {
+ System.err.println(getThreadName() + ": !!! createContextARB: mappedVersionsAvailableSet "+ mappedVersionsAvailableSet);
+ }
if( !mappedVersionsAvailableSet ) {
synchronized(mappedVersionsAvailableLock) {
if( !mappedVersionsAvailableSet ) {
@@ -405,6 +408,9 @@ public abstract class GLContextImpl extends GLContext {
createContextARBMapVersionsAvailable(3, true /* compat */); // GL3bc
createContextARBMapVersionsAvailable(2, true /* compat */); // GL2
mappedVersionsAvailableSet=true;
+ if (DEBUG) {
+ System.err.println(getThreadName() + ": !!! createContextARB: SET mappedVersionsAvailableSet "+ mappedVersionsAvailableSet);
+ }
}
}
}
@@ -497,6 +503,9 @@ public abstract class GLContextImpl extends GLContext {
if(0!=_context) {
destroyContextARBImpl(_context);
mapVersionAvailable(reqMajor, reqProfile, major[0], minor[0], ctp);
+ if (DEBUG) {
+ System.err.println(getThreadName() + ": createContextARBMapVersionsAvailable: "+getGLVersionAvailable(reqMajor, reqProfile));
+ }
}
}
@@ -660,7 +669,7 @@ public abstract class GLContextImpl extends GLContext {
/** Helper routine which resets a ProcAddressTable generated by the
GLEmitter by looking up anew all of its function pointers. */
protected void resetProcAddressTable(Object table) {
- ((ProcAddressTable)table).reset(getDrawableImpl().getDynamicLookupHelper() );
+ ((ProcAddressTable)table).reset(getDrawableImpl().getGLDynamicLookupHelper() );
}
/**
@@ -743,7 +752,7 @@ public abstract class GLContextImpl extends GLContext {
} catch (Exception e) {}
}
// dynamic function lookup at last incl name aliasing (not cached)
- DynamicLookupHelper dynLookup = getDrawableImpl().getDynamicLookupHelper();
+ DynamicLookupHelper dynLookup = getDrawableImpl().getGLDynamicLookupHelper();
String tmpBase = GLExtensionNames.normalizeVEN(GLExtensionNames.normalizeARB(glFunctionName, true), true);
long addr = 0;
int variants = GLExtensionNames.getFuncNamePermutationNumber(tmpBase);
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
index 50e2edddb..6cbed48cd 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
@@ -55,6 +55,13 @@ import java.security.*;
public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
protected static final boolean DEBUG = Debug.debug("GLDrawableFactory");
+ /**
+ * Returns the DynamicLookupHelper
+ * @param profile if EGL/ES, profile <code>1</code> refers to ES1 and <code>2</code> to ES2,
+ * otherwise the profile is ignored.
+ */
+ public abstract GLDynamicLookupHelper getGLDynamicLookupHelper(int profile);
+
//---------------------------------------------------------------------------
// Dispatching GLDrawable construction in respect to the NativeWindow Capabilities
//
@@ -219,11 +226,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
return (GLDrawableFactoryImpl) getFactory(glp);
}
- // Helper function for more lazily loading the GLU library;
- // apparently can't use System.loadLibrary on UNIX because it uses
- // RTLD_LOCAL and we need to call dlsym(RTLD_DEFAULT)
- public abstract void loadGLULibrary();
-
//----------------------------------------------------------------------
// Support for locking and unlocking the toolkit -- needed only on X11 platforms
//
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java
index 62b89a13e..b846b379d 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java
@@ -39,7 +39,6 @@
package com.jogamp.opengl.impl;
-import com.jogamp.common.os.DynamicLookupHelper;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
@@ -58,7 +57,7 @@ public abstract class GLDrawableImpl implements GLDrawable {
/**
* Returns the DynamicLookupHelper
*/
- public abstract DynamicLookupHelper getDynamicLookupHelper();
+ public abstract GLDynamicLookupHelper getGLDynamicLookupHelper();
public GLDrawableFactoryImpl getFactoryImpl() {
return (GLDrawableFactoryImpl) getFactory();
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDynamicLookupHelper.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDynamicLookupHelper.java
new file mode 100755
index 000000000..ce0649997
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDynamicLookupHelper.java
@@ -0,0 +1,184 @@
+/*
+ * 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;
+
+import com.jogamp.common.os.DynamicLookupHelper;
+import com.jogamp.common.os.NativeLibrary;
+import java.util.*;
+import java.security.*;
+import javax.media.opengl.GLException;
+
+/**
+ * Abstract implementation of the DynamicLookupHelper for GL,
+ * which decouples it's dependencies to EGLDrawableFactory.
+ *
+ * Currently two implementations exist, one for ES1 and one for ES2.
+ */
+public abstract class GLDynamicLookupHelper implements DynamicLookupHelper {
+ protected static final boolean DEBUG = com.jogamp.opengl.impl.Debug.debug("GL");
+ protected static final boolean DEBUG_LOOKUP;
+
+ static {
+ AccessControlContext localACC=AccessController.getContext();
+ DEBUG_LOOKUP = com.jogamp.opengl.impl.Debug.isPropertyDefined("jogl.debug.DynamicLookup", true, localACC);
+ }
+
+ protected List/*<NativeLibrary>*/ glLibraries;
+ private long glxGetProcAddressHandle;
+ private String glxGetProcAddressFuncName;
+
+ protected GLDynamicLookupHelper() {
+ glLibraries = new ArrayList();
+ loadGLLibrary();
+ glxGetProcAddressFuncName = getGLXGetProcAddressFuncName();
+ glxGetProcAddressHandle = getGLXGetProcAddressHandle();
+ }
+
+ /** Must return at least one OpenGL library name, eg GL, OpenGL32, .. */
+ protected abstract List/*<String>*/ getGLLibNames();
+
+ /** May return OpenGL Platform library name(s), eg EGL, GLX, .. */
+ protected abstract List/*<String>*/ getGLXLibNames();
+
+ protected boolean shallGLLibLoadedGlobal() { return false; }
+
+ protected boolean shallGLXLibLoadedGlobal() { return false; }
+
+ /** Shall return the OpenGL Platform function name to lookup function pointer, eg eglGetProcAddress */
+ protected abstract String getGLXGetProcAddressFuncName() ;
+
+ protected abstract long dynamicLookupFunctionOnGLX(long glxGetProcAddressHandle, String glFuncName);
+
+ /** Shall load the JNI binding */
+ protected abstract void loadGLJNILibrary();
+
+ /** May load the native GLU library, default: None **/
+ public void loadGLULibrary() { }
+
+ protected long getGLXGetProcAddressHandle() {
+ long aptr = dynamicLookupFunctionOnLibs(glxGetProcAddressFuncName);
+ if(0==aptr) {
+ GLException e = new GLException("Couldn't find "+glxGetProcAddressFuncName+" function entry");
+ if(DEBUG) {
+ e.printStackTrace();
+ }
+ throw e;
+ }
+ return aptr;
+ }
+
+ protected NativeLibrary loadFirstAvailable(List/*<String>*/ libNames, ClassLoader loader, boolean global) {
+ for (Iterator iter = libNames.iterator(); iter.hasNext(); ) {
+ NativeLibrary lib = NativeLibrary.open((String) iter.next(), loader, global);
+ if (lib != null) {
+ return lib;
+ }
+ }
+ return null;
+ }
+
+ private boolean loadGLXLibrary(ClassLoader loader, List/*<String>*/ osLibNames) {
+ if(null!=osLibNames && osLibNames.size()>0) {
+ NativeLibrary lib = loadFirstAvailable(osLibNames, loader, shallGLXLibLoadedGlobal());
+ if ( null != lib ) {
+ glLibraries.add(lib);
+ }
+ return null!=lib;
+ }
+ return true; // none is ok
+ }
+
+ private void loadGLLibrary() {
+ List/*<String>*/ glLibNames = getGLLibNames();
+ List/*<String>*/ osLibNames = getGLXLibNames();
+
+ ClassLoader loader = getClass().getClassLoader();
+ NativeLibrary lib = null;
+
+ // GL libraries ..
+ lib = loadFirstAvailable(glLibNames, loader, shallGLLibLoadedGlobal());
+ if ( null == lib ) {
+ throw new GLException("Unable to dynamically load OpenGL library: "+getClass().getName());
+ }
+ glLibraries.add(lib);
+
+ // GL Platform libraries ..
+ if ( !loadGLXLibrary(loader, osLibNames) ) {
+ throw new GLException("Unable to dynamically load GL Platform library: " + getClass().getName());
+ }
+
+ loadGLJNILibrary();
+ }
+
+ private long dynamicLookupFunctionOnLibs(String glFuncName) {
+ String funcName=glFuncName;
+ long addr = dynamicLookupFunctionOnLibsImpl(funcName);
+ if(DEBUG_LOOKUP) {
+ if(0!=addr) {
+ System.err.println("Lookup-Native: "+glFuncName+" / "+funcName+" 0x"+Long.toHexString(addr));
+ } else {
+ System.err.println("Lookup-Native: "+glFuncName+" / "+funcName+" ** FAILED ** ");
+ }
+ }
+ return addr;
+ }
+
+ private long dynamicLookupFunctionOnLibsImpl(String glFuncName) {
+ // Look up this function name in all known libraries
+ for (Iterator iter = glLibraries.iterator(); iter.hasNext(); ) {
+ NativeLibrary lib = (NativeLibrary) iter.next();
+ long addr = lib.dynamicLookupFunction(glFuncName);
+ if (addr != 0) {
+ return addr;
+ }
+ }
+ return 0;
+ }
+
+ public long dynamicLookupFunction(String glFuncName) {
+ if(null==glFuncName) {
+ return 0;
+ }
+
+ if(glFuncName.equals(glxGetProcAddressFuncName)) {
+ return glxGetProcAddressHandle;
+ }
+
+ long addr = dynamicLookupFunctionOnGLX(glxGetProcAddressHandle, glFuncName);
+ if(DEBUG_LOOKUP) {
+ if(0!=addr) {
+ System.err.println("Lookup: <"+glFuncName+"> 0x"+Long.toHexString(addr));
+ }
+ }
+ if(0==addr) {
+ addr = dynamicLookupFunctionOnLibs(glFuncName);
+ }
+ return addr;
+ }
+}
+
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 e64b5bcf2..56ae649be 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java
@@ -242,7 +242,7 @@ public abstract class EGLContext extends GLContextImpl {
public synchronized String getPlatformExtensionsString() {
if (!eglQueryStringInitialized) {
eglQueryStringAvailable =
- getDrawableImpl().getDynamicLookupHelper().dynamicLookupFunction("eglQueryString") != 0;
+ getDrawableImpl().getGLDynamicLookupHelper().dynamicLookupFunction("eglQueryString") != 0;
eglQueryStringInitialized = true;
}
if (eglQueryStringAvailable) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java
index 2e24abcec..a36973de1 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java
@@ -35,7 +35,7 @@
package com.jogamp.opengl.impl.egl;
-import com.jogamp.common.os.DynamicLookupHelper;
+import com.jogamp.opengl.impl.GLDynamicLookupHelper;
import com.jogamp.opengl.impl.GLDrawableImpl;
import javax.media.nativewindow.*;
@@ -208,8 +208,8 @@ public abstract class EGLDrawable extends GLDrawableImpl {
return tmp[0];
}
- public DynamicLookupHelper getDynamicLookupHelper() {
- return EGLDynamicLookupHelper.getDynamicLookupHelper(getGLProfile());
+ public GLDynamicLookupHelper getGLDynamicLookupHelper() {
+ return EGLDynamicLookupHelper.getEGLDynamicLookupHelper(getGLProfile());
}
public String toString() {
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 fb0da9c40..f74c7858f 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
@@ -61,6 +61,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
super();
}
+ public GLDynamicLookupHelper getGLDynamicLookupHelper(int esProfile) {
+ return EGLDynamicLookupHelper.getEGLDynamicLookupHelper(esProfile);
+ }
+
protected void shutdown() {}
protected final GLDrawableImpl getSharedDrawable() { return null; }
protected final GLContextImpl getSharedContext() { return null; }
@@ -103,9 +107,6 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
throw new GLException("Not yet implemented");
}
- public void loadGLULibrary() {
- }
-
public boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device) {
return false;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDynamicLookupHelper.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDynamicLookupHelper.java
index 9e34dc9e9..28cfb4f1e 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDynamicLookupHelper.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDynamicLookupHelper.java
@@ -1,36 +1,28 @@
/*
- * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
- *
+ * 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 of Sun Microsystems, Inc. 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
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ * 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.egl;
@@ -45,22 +37,15 @@ import java.security.*;
/**
* Abstract implementation of the DynamicLookupHelper for EGL,
- * which decouples it's dependencies to EGLDrawableFactory.
+ * which decouples it's dependencies to EGLDrawable.
*
* Currently two implementations exist, one for ES1 and one for ES2.
*/
-public abstract class EGLDynamicLookupHelper implements DynamicLookupHelper {
- protected static final boolean DEBUG = com.jogamp.opengl.impl.Debug.debug("EGL");
- protected static final boolean DEBUG_LOOKUP;
-
+public abstract class EGLDynamicLookupHelper extends GLDynamicLookupHelper {
private static final EGLDynamicLookupHelper eglES1DynamicLookupHelper;
private static final EGLDynamicLookupHelper eglES2DynamicLookupHelper;
- private List/*<NativeLibrary>*/ glesLibraries;
static {
- AccessControlContext localACC=AccessController.getContext();
- DEBUG_LOOKUP = com.jogamp.opengl.impl.Debug.isPropertyDefined("jogl.debug.DynamicLookup", true, localACC);
-
EGLDynamicLookupHelper tmp=null;
try {
tmp = new EGLES1DynamicLookupHelper();
@@ -82,23 +67,17 @@ public abstract class EGLDynamicLookupHelper implements DynamicLookupHelper {
eglES2DynamicLookupHelper = tmp;
}
- public static EGLDynamicLookupHelper getDynamicLookupHelper(GLProfile glp) {
+ public static EGLDynamicLookupHelper getEGLDynamicLookupHelper(GLProfile glp) {
if (glp.usesNativeGLES2()) {
- if(null==eglES2DynamicLookupHelper) {
- throw new GLException("EGLDynamicLookupHelper for ES2 not available");
- }
- return eglES2DynamicLookupHelper;
+ return getEGLDynamicLookupHelper(2);
} else if (glp.usesNativeGLES1()) {
- if(null==eglES1DynamicLookupHelper) {
- throw new GLException("EGLDynamicLookupHelper for ES1 not available");
- }
- return eglES1DynamicLookupHelper;
+ return getEGLDynamicLookupHelper(1);
} else {
throw new GLException("Unsupported: "+glp);
}
}
- public static EGLDynamicLookupHelper getDynamicLookupHelper(int esProfile) {
+ public static EGLDynamicLookupHelper getEGLDynamicLookupHelper(int esProfile) {
if (2==esProfile) {
if(null==eglES2DynamicLookupHelper) {
throw new GLException("EGLDynamicLookupHelper for ES2 not available");
@@ -115,18 +94,14 @@ public abstract class EGLDynamicLookupHelper implements DynamicLookupHelper {
}
protected EGLDynamicLookupHelper() {
- loadGLESLibrary(getESProfile());
+ super();
EGL.resetProcAddressTable(this);
}
- /** Must return the proper ES profile number, 1 for ES1 and 2 for ES2 */
- protected abstract int getESProfile();
-
- /** Must return at least one OpenGL ES library name */
- protected abstract List/*<String>*/ getGLESLibNames();
+ protected boolean hasESBinding = false;
+ public boolean hasESBinding() { return hasESBinding; }
- /** May return OpenGL ES library name(s) */
- protected List/*<String>*/ getEGLLibNames() {
+ protected final List/*<String>*/ getGLXLibNames() {
List/*<String>*/ eglLibNames = new ArrayList();
// EGL
@@ -138,133 +113,12 @@ public abstract class EGLDynamicLookupHelper implements DynamicLookupHelper {
return eglLibNames;
}
- private NativeLibrary loadFirstAvailable(List/*<String>*/ libNames, ClassLoader loader) {
- for (Iterator iter = libNames.iterator(); iter.hasNext(); ) {
- NativeLibrary lib = NativeLibrary.open((String) iter.next(), loader, false /*global*/);
- if (lib != null) {
- return lib;
- }
- }
- return null;
- }
-
- private boolean loadEGLLibrary(ClassLoader loader, List/*<String>*/ eglLibNames) {
- NativeLibrary lib = null;
- if(null!=eglLibNames && eglLibNames.size()>0) {
- // EGL libraries ..
- lib = loadFirstAvailable(eglLibNames, loader);
- if ( null != lib ) {
- glesLibraries.add(lib);
- }
- }
- return null!=lib;
- }
-
- private void loadGLESLibrary(int esProfile) {
- List/*<String>*/ glesLibNames = getGLESLibNames();
- List/*<String>*/ eglLibNames = getEGLLibNames();
- boolean eglLoaded = false;
-
- ClassLoader loader = getClass().getClassLoader();
- NativeLibrary lib = null;
-
- glesLibraries = new ArrayList();
-
- // ES libraries ..
- lib = loadFirstAvailable(glesLibNames, loader);
- if ( null == lib ) {
- /*** FIXME: Have to think about this ..
- // try again with EGL loaded first ..
- if ( !eglLoaded && loadEGLLibrary(loader, eglLibNames) ) {
- eglLoaded = true ;
- lib = loadFirstAvailable(glesLibNames, loader);
- }
- if ( null == lib ) {
- throw new GLException("Unable to dynamically load OpenGL ES library for profile ES" + esProfile);
- } */
- throw new GLException("Unable to dynamically load OpenGL ES library for profile ES" + esProfile);
- }
- glesLibraries.add(lib);
-
- if ( !eglLoaded && !loadEGLLibrary(loader, eglLibNames) ) {
- throw new GLException("Unable to dynamically load EGL library for profile ES" + esProfile);
- }
-
- if (esProfile==2) {
- GLJNILibLoader.loadES2();
- } else if (esProfile==1) {
- GLJNILibLoader.loadES1();
- } else {
- throw new GLException("Unsupported: ES"+esProfile);
- }
- }
-
- private long dynamicLookupFunctionOnLibs(String glFuncName) {
- String funcName=glFuncName;
- long addr = dynamicLookupFunctionOnLibsImpl(funcName);
- if( 0==addr && NativeWindowFactory.TYPE_WINDOWS.equals(NativeWindowFactory.getNativeWindowType(false)) ) {
- // Hack: try some C++ decoration here for Imageon's emulation libraries ..
- final int argAlignment=4; // 4 byte alignment of each argument
- final int maxArguments=12; // experience ..
- for(int arg=0; 0==addr && arg<=maxArguments; arg++) {
- funcName = "_"+glFuncName+"@"+(arg*argAlignment);
- addr = dynamicLookupFunctionOnLibsImpl(funcName);
- }
- }
- if(DEBUG_LOOKUP) {
- if(0!=addr) {
- System.err.println("Lookup-Native: "+glFuncName+" / "+funcName+" 0x"+Long.toHexString(addr));
- } else {
- System.err.println("Lookup-Native: "+glFuncName+" / "+funcName+" ** FAILED ** ");
- }
- }
- return addr;
+ protected final String getGLXGetProcAddressFuncName() {
+ return "eglGetProcAddress" ;
}
- private long dynamicLookupFunctionOnLibsImpl(String glFuncName) {
- // Look up this function name in all known libraries
- for (Iterator iter = glesLibraries.iterator(); iter.hasNext(); ) {
- NativeLibrary lib = (NativeLibrary) iter.next();
- long addr = lib.dynamicLookupFunction(glFuncName);
- if (addr != 0) {
- return addr;
- }
- }
- return 0;
- }
-
- private long eglGetProcAddressHandle = 0;
-
- public long dynamicLookupFunction(String glFuncName) {
- if(null==glFuncName) {
- return 0;
- }
-
- // bootstrap eglGetProcAddress
- if(0==eglGetProcAddressHandle) {
- eglGetProcAddressHandle = dynamicLookupFunctionOnLibs("eglGetProcAddress");
- if(0==eglGetProcAddressHandle) {
- GLException e = new GLException("Couldn't find eglGetProcAddress function entry");
- if(DEBUG) {
- e.printStackTrace();
- }
- throw e;
- }
- }
-
- if(glFuncName.equals("eglGetProcAddress")) {
- return eglGetProcAddressHandle;
- }
-
- long addr = EGL.eglGetProcAddress(eglGetProcAddressHandle, glFuncName);
- if(DEBUG_LOOKUP) {
- if(0!=addr) {
- System.err.println("Lookup-EGL: <"+glFuncName+"> 0x"+Long.toHexString(addr));
- }
- }
- if(0==addr) {
- addr = dynamicLookupFunctionOnLibs(glFuncName);
- }
- return addr;
+ protected final long dynamicLookupFunctionOnGLX(long glxGetProcAddressHandle, String glFuncName) {
+ return EGL.eglGetProcAddress(glxGetProcAddressHandle, glFuncName);
}
}
+
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLES1DynamicLookupHelper.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLES1DynamicLookupHelper.java
index e5740a4f0..9599e1457 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLES1DynamicLookupHelper.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLES1DynamicLookupHelper.java
@@ -1,41 +1,34 @@
/*
- * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
- *
+ * 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 of Sun Microsystems, Inc. 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
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ * 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.egl;
import java.util.*;
+import com.jogamp.opengl.impl.*;
/**
* Implementation of the EGLDynamicLookupHelper for ES1.
@@ -46,11 +39,27 @@ public class EGLES1DynamicLookupHelper extends EGLDynamicLookupHelper {
super();
}
- protected int getESProfile() {
- return 1;
+ protected void loadGLJNILibrary() {
+ Throwable t=null;
+ try {
+ GLJNILibLoader.loadES1();
+ hasESBinding = true;
+ } catch (UnsatisfiedLinkError ule) {
+ t=ule;
+ } catch (SecurityException se) {
+ t=se;
+ } catch (NullPointerException npe) {
+ t=npe;
+ } catch (RuntimeException re) {
+ t=re;
+ }
+ if(DEBUG && null!=t) {
+ System.err.println("EGLES1DynamicLookupHelper: ES1 Binding Library not available");
+ t.printStackTrace();
+ }
}
- protected List/*<String>*/ getGLESLibNames() {
+ protected List/*<String>*/ getGLLibNames() {
List/*<String>*/ glesLibNames = new ArrayList();
glesLibNames.add("GLES_CM");
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLES2DynamicLookupHelper.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLES2DynamicLookupHelper.java
index c4fc66630..c00fa0e93 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLES2DynamicLookupHelper.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLES2DynamicLookupHelper.java
@@ -1,41 +1,34 @@
/*
- * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
- *
+ * 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 of Sun Microsystems, Inc. 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
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ * 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.egl;
import java.util.*;
+import com.jogamp.opengl.impl.*;
/**
* Implementation of the EGLDynamicLookupHelper for ES2.
@@ -46,11 +39,27 @@ public class EGLES2DynamicLookupHelper extends EGLDynamicLookupHelper {
super();
}
- protected int getESProfile() {
- return 2;
+ protected void loadGLJNILibrary() {
+ Throwable t=null;
+ try {
+ GLJNILibLoader.loadES2();
+ hasESBinding = true;
+ } catch (UnsatisfiedLinkError ule) {
+ t=ule;
+ } catch (SecurityException se) {
+ t=se;
+ } catch (NullPointerException npe) {
+ t=npe;
+ } catch (RuntimeException re) {
+ t=re;
+ }
+ if(DEBUG && null!=t) {
+ System.err.println("EGLES2DynamicLookupHelper: ES2 Binding Library not available");
+ t.printStackTrace();
+ }
}
- protected List/*<String>*/ getGLESLibNames() {
+ protected List/*<String>*/ getGLLibNames() {
List/*<String>*/ glesLibNames = new ArrayList();
glesLibNames.add("GLES20");
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java
index cf29d214b..3f41d95cb 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java
@@ -92,8 +92,8 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
}
}
- public DynamicLookupHelper getDynamicLookupHelper() {
- return (MacOSXCGLDrawableFactory) getFactoryImpl() ;
+ public GLDynamicLookupHelper getGLDynamicLookupHelper() {
+ return MacOSXCGLDynamicLookupHelper.getMacOSXCGLDynamicLookupHelper();
}
protected static String getThreadName() {
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 61d24a106..e507e4886 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
@@ -39,7 +39,6 @@
package com.jogamp.opengl.impl.macosx.cgl;
-import com.jogamp.common.os.DynamicLookupHelper;
import java.nio.*;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
@@ -48,7 +47,12 @@ import com.jogamp.common.util.*;
import com.jogamp.opengl.impl.*;
import com.jogamp.nativewindow.impl.NullWindow;
-public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl implements DynamicLookupHelper {
+public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
+
+ public GLDynamicLookupHelper getGLDynamicLookupHelper(int profile) {
+ return MacOSXCGLDynamicLookupHelper.getMacOSXCGLDynamicLookupHelper();
+ }
+
public MacOSXCGLDrawableFactory() {
super();
@@ -56,6 +60,8 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl implements D
// The act of constructing them causes them to be registered
new MacOSXCGLGraphicsConfigurationFactory();
+ MacOSXCGLDynamicLookupHelper.getMacOSXCGLDynamicLookupHelper(); // setup and initialize
+
try {
ReflectionUtil.createInstance("com.jogamp.opengl.impl.macosx.cgl.awt.MacOSXAWTCGLGraphicsConfigurationFactory",
new Object[] {});
@@ -118,15 +124,6 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl implements D
throw new GLException("Not yet implemented");
}
- public void loadGLULibrary() {
- // Nothing to do; already loaded by native code; not much point in
- // making it lazier on this platform
- }
-
- public long dynamicLookupFunction(String glFuncName) {
- return CGL.getProcAddress(glFuncName);
- }
-
public boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device) {
return false;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDynamicLookupHelper.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDynamicLookupHelper.java
new file mode 100644
index 000000000..3ed75b245
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDynamicLookupHelper.java
@@ -0,0 +1,93 @@
+/*
+ * 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.macosx.cgl;
+
+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 MacOSXCGLDynamicLookupHelper extends DesktopGLDynamicLookupHelper {
+ private static final MacOSXCGLDynamicLookupHelper macOSXCGLDynamicLookupHelper;
+
+ static {
+ MacOSXCGLDynamicLookupHelper tmp = null;
+ try {
+ tmp = new MacOSXCGLDynamicLookupHelper();
+ } catch (GLException gle) {
+ if(DEBUG) {
+ gle.printStackTrace();
+ }
+ }
+ macOSXCGLDynamicLookupHelper = tmp;
+ }
+
+ public static MacOSXCGLDynamicLookupHelper getMacOSXCGLDynamicLookupHelper() {
+ return macOSXCGLDynamicLookupHelper;
+ }
+
+ protected MacOSXCGLDynamicLookupHelper() {
+ super();
+ }
+
+ public synchronized void loadGLULibrary() {
+ if(null==gluLib) {
+ List/*<String>*/ gluLibNames = new ArrayList();
+ gluLibNames.add("/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib");
+ gluLibNames.add("GLU");
+ gluLib = loadFirstAvailable(gluLibNames, null, false);
+ if(null != gluLib) {
+ glLibraries.add(gluLib);
+ }
+ }
+ }
+ NativeLibrary gluLib = null;
+
+ protected final List/*<String>*/ getGLLibNames() {
+ List/*<String>*/ glesLibNames = new ArrayList();
+ glesLibNames.add("/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib");
+ glesLibNames.add("GL");
+ return glesLibNames;
+ }
+
+ protected final List/*<String>*/ getGLXLibNames() {
+ return null;
+ }
+
+ protected final String getGLXGetProcAddressFuncName() {
+ return "getProcAddress" ; // dummy
+ }
+
+ protected long dynamicLookupFunctionOnGLX(long glxGetProcAddressHandle, String glFuncName) {
+ return CGL.getProcAddress(glFuncName); // manual implementation
+ }
+}
+
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 e52c585de..3ecd3bdbc 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
@@ -243,8 +243,8 @@ public class WindowsWGLContext extends GLContextImpl {
setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
if( createContextARBTried ||
- !isFunctionAvailable("wglCreateContextAttribsARB") ||
- !isExtensionAvailable("WGL_ARB_create_context") ) {
+ !isFunctionAvailable("wglCreateContextAttribsARB") /* ||
+ !isExtensionAvailable("WGL_ARB_create_context") */ ) { // unresolved case where client version is 1.4 without this extension
if(glCaps.getGLProfile().isGL3()) {
WGL.wglMakeCurrent(0, 0);
WGL.wglDeleteContext(temp_ctx);
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java
index 43c1ff5e0..274390b2c 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java
@@ -39,7 +39,6 @@
package com.jogamp.opengl.impl.windows.wgl;
-import com.jogamp.common.os.DynamicLookupHelper;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.jogamp.opengl.impl.*;
@@ -119,8 +118,8 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl {
}
}
- public DynamicLookupHelper getDynamicLookupHelper() {
- return (WindowsWGLDrawableFactory) getFactoryImpl() ;
+ public GLDynamicLookupHelper getGLDynamicLookupHelper() {
+ return WindowsWGLDynamicLookupHelper.getWindowsWGLDynamicLookupHelper();
}
protected static String getThreadName() {
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 d2eb98bdf..8072ad2de 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
@@ -39,7 +39,6 @@
package com.jogamp.opengl.impl.windows.wgl;
-import com.jogamp.common.os.DynamicLookupHelper;
import java.nio.*;
import java.util.*;
import javax.media.nativewindow.*;
@@ -50,15 +49,12 @@ import com.jogamp.common.util.*;
import com.jogamp.opengl.impl.*;
import com.jogamp.nativewindow.impl.NullWindow;
-public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements DynamicLookupHelper {
+public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
private static final boolean VERBOSE = Debug.verbose();
- // Handle to GLU32.dll
- // FIXME: this should go away once we delete support for the C GLU library
- private long hglu32;
-
- // Handle to core OpenGL32.dll
- private long hopengl32;
+ public GLDynamicLookupHelper getGLDynamicLookupHelper(int profile) {
+ return WindowsWGLDynamicLookupHelper.getWindowsWGLDynamicLookupHelper();
+ }
public WindowsWGLDrawableFactory() {
super();
@@ -66,13 +62,12 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
// Register our GraphicsConfigurationFactory implementations
// The act of constructing them causes them to be registered
new WindowsWGLGraphicsConfigurationFactory();
+ WindowsWGLDynamicLookupHelper.getWindowsWGLDynamicLookupHelper(); // setup and load ..
try {
ReflectionUtil.createInstance("com.jogamp.opengl.impl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory",
new Object[] {});
} catch (JogampRuntimeException jre) { /* n/a .. */ }
- loadOpenGL32Library();
-
try {
sharedDrawable = new WindowsDummyWGLDrawable(this, null);
WindowsWGLContext ctx = (WindowsWGLContext) sharedDrawable.createContext(null);
@@ -194,44 +189,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
return WindowsExternalWGLDrawable.create(this, null);
}
- public void loadOpenGL32Library() {
- if (hopengl32 == 0) {
- hopengl32 = WGL.LoadLibraryA("OpenGL32");
- if (DEBUG) {
- if (hopengl32 == 0) {
- System.err.println("WindowsWGLDrawableFactory: Could not load OpenGL32.dll - maybe an embedded device");
- }
- }
- }
- }
-
- public void loadGLULibrary() {
- if (hglu32 == 0) {
- hglu32 = WGL.LoadLibraryA("GLU32");
- if (hglu32 == 0) {
- throw new GLException("Error loading GLU32.DLL");
- }
- }
- }
-
- public long dynamicLookupFunction(String glFuncName) {
- long res = WGL.wglGetProcAddress(glFuncName);
- if (res == 0) {
- // It may happen that a driver doesn't return the OpenGL32 core function pointer
- // with wglGetProcAddress (e.g. NVidia GL 3.1) - hence we have to look harder.
- if (hopengl32 != 0) {
- res = WGL.GetProcAddress(hopengl32, glFuncName);
- }
- }
- if (res == 0) {
- // GLU routines aren't known to the OpenGL function lookup
- if (hglu32 != 0) {
- res = WGL.GetProcAddress(hglu32, glFuncName);
- }
- }
- return res;
- }
-
static String wglGetLastError() {
long err = WGL.GetLastError();
String detail = null;
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDynamicLookupHelper.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDynamicLookupHelper.java
new file mode 100644
index 000000000..d0b0acaa3
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDynamicLookupHelper.java
@@ -0,0 +1,91 @@
+/*
+ * 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.windows.wgl;
+
+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 WindowsWGLDynamicLookupHelper extends DesktopGLDynamicLookupHelper {
+ private static final WindowsWGLDynamicLookupHelper windowsWGLDynamicLookupHelper;
+
+ static {
+ WindowsWGLDynamicLookupHelper tmp = null;
+ try {
+ tmp = new WindowsWGLDynamicLookupHelper();
+ } catch (GLException gle) {
+ if(DEBUG) {
+ gle.printStackTrace();
+ }
+ }
+ windowsWGLDynamicLookupHelper = tmp;
+ }
+
+ public static WindowsWGLDynamicLookupHelper getWindowsWGLDynamicLookupHelper() {
+ return windowsWGLDynamicLookupHelper;
+ }
+
+ protected WindowsWGLDynamicLookupHelper() {
+ super();
+ }
+
+ public synchronized void loadGLULibrary() {
+ if(null==gluLib) {
+ List/*<String>*/ gluLibNames = new ArrayList();
+ gluLibNames.add("GLU32");
+ gluLib = loadFirstAvailable(gluLibNames, null, false);
+ if(null != gluLib) {
+ glLibraries.add(gluLib);
+ }
+ }
+ }
+ NativeLibrary gluLib = null;
+
+ protected final List/*<String>*/ getGLLibNames() {
+ List/*<String>*/ glesLibNames = new ArrayList();
+ glesLibNames.add("OpenGL32");
+ return glesLibNames;
+ }
+
+ protected final List/*<String>*/ getGLXLibNames() {
+ return null;
+ }
+
+ protected final String getGLXGetProcAddressFuncName() {
+ return "wglGetProcAddress" ;
+ }
+
+ protected long dynamicLookupFunctionOnGLX(long glxGetProcAddressHandle, String glFuncName) {
+ return WGL.wglGetProcAddress(glFuncName);
+ }
+}
+
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);
+ }
+}
+
+