diff options
author | Kenneth Russel <[email protected]> | 2008-05-28 03:04:38 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2008-05-28 03:04:38 +0000 |
commit | 75f83018930f6594b29f16459c1e91b54842924b (patch) | |
tree | f19e352eca6d33f2a57fde0cf331651a9727912f /src/classes/com | |
parent | 95c3974708231607d729830ae711a0864a961b71 (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
Diffstat (limited to 'src/classes/com')
-rwxr-xr-x | src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java | 68 |
1 files changed, 59 insertions, 9 deletions
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() { |