summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--make/build.xml8
-rw-r--r--make/glu-CustomJavaCode.java11
-rwxr-xr-xmake/glx-CustomCCode.c11
-rw-r--r--make/glx-x11.cfg1
-rw-r--r--src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java5
-rw-r--r--src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java5
-rw-r--r--src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java17
-rw-r--r--src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java4
8 files changed, 52 insertions, 10 deletions
diff --git a/make/build.xml b/make/build.xml
index 1e7d614f1..1f251e82d 100644
--- a/make/build.xml
+++ b/make/build.xml
@@ -701,19 +701,19 @@
<!-- linker configuration -->
<linker id="linker.cfg.linux" name="gcc">
- <syslibset dir="/usr/X11R6/lib" libs="GL, GLU, X11"/>
+ <syslibset dir="/usr/X11R6/lib" libs="GL, X11"/>
<syslibset dir="/usr/X11R6/lib" libs="Xxf86vm" />
<syslibset dir="${x11.cg.lib}" libs="Cg, CgGL" if="c.compiler.use-cglib"/>
</linker>
<linker id="linker.cfg.linux.amd64" name="gcc">
- <syslibset dir="/usr/X11R6/lib64" libs="GL, GLU, X11"/>
+ <syslibset dir="/usr/X11R6/lib64" libs="GL, X11"/>
<syslibset dir="/usr/X11R6/lib64" libs="Xxf86vm" />
<syslibset dir="${x11.cg.lib}" libs="Cg, CgGL" if="c.compiler.use-cglib"/>
</linker>
<linker id="linker.cfg.solaris" name="suncc">
- <syslibset libs="GL, GLU, X11"/>
+ <syslibset libs="GL, X11"/>
</linker>
<linker id="linker.cfg.win32.mingw" name="gcc" incremental="false">
@@ -727,7 +727,7 @@
<linkerarg value="/SUBSYSTEM:WINDOWS" /> <!-- output is not a console app as uses WinMain entry point -->
<linkerarg value="/MACHINE:IX86" /> <!-- explicity set target platform -->
- <syslibset libs="opengl32, glu32, gdi32, user32, kernel32" />
+ <syslibset libs="opengl32, gdi32, user32, kernel32" />
<syslibset dir="${windows.cg.lib}" libs="cg, cgGL" if="c.compiler.use-cglib"/>
</linker>
diff --git a/make/glu-CustomJavaCode.java b/make/glu-CustomJavaCode.java
index ffa3a0242..1ea4f20b9 100644
--- a/make/glu-CustomJavaCode.java
+++ b/make/glu-CustomJavaCode.java
@@ -1432,8 +1432,12 @@ public int gluScaleImage(int format, int wIn, int hIn, int typeIn, java.nio.Buff
//
private static GLUProcAddressTable gluProcAddressTable;
+private static volatile boolean gluLibraryLoaded;
private static GLUProcAddressTable getGLUProcAddressTable() {
+ if (!gluLibraryLoaded) {
+ loadGLULibrary();
+ }
if (gluProcAddressTable == null) {
GLUProcAddressTable tmp = new GLUProcAddressTable();
ProcAddressHelper.resetProcAddressTable(tmp, GLDrawableFactoryImpl.getFactoryImpl());
@@ -1441,3 +1445,10 @@ private static GLUProcAddressTable getGLUProcAddressTable() {
}
return gluProcAddressTable;
}
+
+private static synchronized void loadGLULibrary() {
+ if (!gluLibraryLoaded) {
+ GLDrawableFactoryImpl.getFactoryImpl().loadGLULibrary();
+ gluLibraryLoaded = true;
+ }
+}
diff --git a/make/glx-CustomCCode.c b/make/glx-CustomCCode.c
index 504b8432f..791927604 100755
--- a/make/glx-CustomCCode.c
+++ b/make/glx-CustomCCode.c
@@ -51,6 +51,17 @@ JNIEXPORT jlong JNICALL
Java_com_sun_opengl_impl_x11_GLX_RootWindow(JNIEnv *env, jclass _unused, jlong display, jint screen) {
return RootWindow((Display*) (intptr_t) display, screen);
}
+
+JNIEXPORT jlong JNICALL
+Java_com_sun_opengl_impl_x11_GLX_dlopen(JNIEnv *env, jclass _unused, jstring name) {
+ const jbyte* chars;
+ void* res;
+ chars = (*env)->GetStringUTFChars(env, name, NULL);
+ res = dlopen(chars, RTLD_LAZY | RTLD_GLOBAL);
+ (*env)->ReleaseStringUTFChars(env, name, chars);
+ return (jlong) ((intptr_t) res);
+}
+
JNIEXPORT jlong JNICALL
Java_com_sun_opengl_impl_x11_GLX_dlsym(JNIEnv *env, jclass _unused, jstring name) {
const jbyte* chars;
diff --git a/make/glx-x11.cfg b/make/glx-x11.cfg
index 5680a419a..93ff2d02f 100644
--- a/make/glx-x11.cfg
+++ b/make/glx-x11.cfg
@@ -13,6 +13,7 @@ SkipProcAddressGen glXGetProcAddressARB
CustomJavaCode GLX private static GLXProcAddressTable glxProcAddressTable = new GLXProcAddressTable();
CustomJavaCode GLX public static GLXProcAddressTable getGLXProcAddressTable() { return glxProcAddressTable; }
+CustomJavaCode GLX public static native long dlopen(String name);
CustomJavaCode GLX public static native long dlsym(String name);
IncludeAs CustomCCode glx-CustomCCode.c
diff --git a/src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java b/src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
index 45a875361..3f9580cc7 100644
--- a/src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
+++ b/src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
@@ -75,6 +75,11 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory implements
return (GLDrawableFactoryImpl) getFactory();
}
+ // 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();
+
//----------------------------------------------------------------------
// Gamma adjustment support
// Thanks to the LWJGL team for illustrating how to make these
diff --git a/src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java
index fbc52e850..facf9e648 100644
--- a/src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java
+++ b/src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java
@@ -118,6 +118,11 @@ public class MacOSXGLDrawableFactory extends GLDrawableFactoryImpl {
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);
}
diff --git a/src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java
index eab068bb4..94fd0eb1e 100644
--- a/src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java
+++ b/src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java
@@ -173,17 +173,22 @@ public class WindowsGLDrawableFactory extends GLDrawableFactoryImpl {
return new WindowsExternalGLDrawable();
}
+ 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) {
// GLU routines aren't known to the OpenGL function lookup
- if (hglu32 == 0) {
- hglu32 = WGL.LoadLibraryA("GLU32");
- if (hglu32 == 0) {
- throw new GLException("Error loading GLU32.DLL");
- }
+ if (hglu32 != 0) {
+ res = WGL.GetProcAddress(hglu32, glFuncName);
}
- res = WGL.GetProcAddress(hglu32, glFuncName);
}
return res;
}
diff --git a/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java b/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java
index 6d6f02441..248371c37 100644
--- a/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java
+++ b/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java
@@ -261,6 +261,10 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl {
return new X11ExternalGLDrawable();
}
+ public void loadGLULibrary() {
+ GLX.dlopen("/usr/lib/libGLU.so");
+ }
+
public long dynamicLookupFunction(String glFuncName) {
long res = 0;
if (!isLinuxAMD64) {