aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2008-05-28 03:04:38 +0000
committerKenneth Russel <[email protected]>2008-05-28 03:04:38 +0000
commit75f83018930f6594b29f16459c1e91b54842924b (patch)
treef19e352eca6d33f2a57fde0cf331651a9727912f
parent95c3974708231607d729830ae711a0864a961b71 (diff)
Implemented dynamic function lookup in EGLDrawableFactory and
initialization of the EGL ProcAddressTable which should allow bootstrapping, at least on Windows and/or the NVidia APX 2500. Not yet tested. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1644 232f8b59-042b-4e1e-8c03-345bb8c30851
-rwxr-xr-xmake/egl.cfg3
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java68
2 files changed, 62 insertions, 9 deletions
diff --git a/make/egl.cfg b/make/egl.cfg
index f699f7515..2ae90b53b 100755
--- a/make/egl.cfg
+++ b/make/egl.cfg
@@ -85,6 +85,9 @@ CustomCCode #include <inttypes.h>
CustomCCode #endif
CustomJavaCode EGL private static EGLProcAddressTable _table = new EGLProcAddressTable();
+CustomJavaCode EGL public static void resetProcAddressTable(DynamicLookupHelper lookup) {
+CustomJavaCode EGL ProcAddressHelper.resetProcAddressTable(_table, lookup);
+CustomJavaCode EGL }
# There are some #defines in egl.h that GlueGen and PCPP don't currently handle
CustomJavaCode EGL public static final long EGL_DEFAULT_DISPLAY = 0;
diff --git a/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
index 667afc2ac..bbef9a54f 100755
--- a/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
@@ -35,14 +35,19 @@
package com.sun.opengl.impl.egl;
+import java.util.*;
import javax.media.opengl.*;
import com.sun.opengl.impl.*;
+import com.sun.gluegen.runtime.NativeLibrary;
public class EGLDrawableFactory extends GLDrawableFactoryImpl {
static {
NativeLibLoader.loadCore();
}
+ // We need more than one of these on certain devices (the NVidia APX 2500 in particular)
+ private List/*<NativeLibrary>*/ glesLibraries;
+
// FIXME: this state should probably not be here
private long display;
private _EGLConfig config;
@@ -50,6 +55,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
public EGLDrawableFactory(String profile) {
super(profile);
+ loadGLESLibrary();
+ EGL.resetProcAddressTable(this);
+
// FIXME: this initialization sequence needs to be refactored
// at least for X11 platforms to allow a little window
// system-specific code to run (to open the display, in
@@ -64,6 +72,46 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
}
}
+ private void loadGLESLibrary() {
+ List/*<NativeLibrary>*/ libs = new ArrayList();
+
+ // Try several variants
+ List/*<String>*/ glesLibNames = new ArrayList();
+ // Windows
+ glesLibNames.add("libGLES_CM");
+ glesLibNames.add("libGLES_CL");
+ // Unix
+ glesLibNames.add("GLES_CM");
+ glesLibNames.add("GLES_CL");
+ // NVidia APX 2500
+ if (PROFILE_GLES2.equals(getProfile())) {
+ glesLibNames.add("libGLESv2_CM");
+ glesLibNames.add("GLESv2_CM");
+ } else {
+ glesLibNames.add("libGLESv1_CM");
+ glesLibNames.add("GLESv1_CM");
+ }
+
+ ClassLoader loader = getClass().getClassLoader();
+ for (Iterator iter = glesLibNames.iterator(); iter.hasNext(); ) {
+ NativeLibrary lib = NativeLibrary.open((String) iter.next(), loader);
+ if (lib != null) {
+ libs.add(lib);
+ break;
+ }
+ }
+
+ if (libs.isEmpty()) {
+ throw new GLException("Unable to dynamically load OpenGL ES library for profile \"" + getProfile() + "\"");
+ }
+
+ // On the NVidia APX 2500 we need to separately load the EGL library
+ NativeLibrary eglLib = NativeLibrary.open("libEGL", loader);
+ if (eglLib != null) {
+ libs.add(eglLib);
+ }
+ glesLibraries = libs;
+ }
public AbstractGraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities,
GLCapabilitiesChooser chooser,
@@ -112,17 +160,19 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
}
public long dynamicLookupFunction(String glFuncName) {
- return 0;
- /*
- long res = WGL.wglGetProcAddress(glFuncName);
- if (res == 0) {
- // GLU routines aren't known to the OpenGL function lookup
- if (hglu32 != 0) {
- res = WGL.GetProcAddress(hglu32, glFuncName);
+ // Look up this function name in all known libraries
+ //
+ // Note that we aren't using eglGetProcAddress; maybe we
+ // should once it's bootstrapped (FIXME)
+ for (Iterator iter = glesLibraries.iterator(); iter.hasNext(); ) {
+ NativeLibrary lib = (NativeLibrary) iter.next();
+ long addr = lib.lookupFunction(glFuncName);
+ if (addr != 0) {
+ return addr;
}
}
- return res;
- */
+
+ return 0;
}
public void lockAWTForJava2D() {