diff options
38 files changed, 863 insertions, 765 deletions
diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 0dd04ccb8..9203542a7 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -1103,13 +1103,12 @@ <!-- linker configuration --> - <linker id="linker.cfg.linux.jogl.gl2" extends="linker.cfg.linux"> + <linker id="linker.cfg.linux.jogl.x11" extends="linker.cfg.linux"> <syslibset libs="X11"/> <syslibset libs="Xxf86vm" /> - <syslibset libs="GL"/> </linker> - <linker id="linker.cfg.linux.jogl.cg" extends="linker.cfg.linux.jogl.gl2"> + <linker id="linker.cfg.linux.jogl.cg" extends="linker.cfg.linux.jogl.x11"> <syslibset dir="${x11.cg.lib32}" libs="Cg, CgGL"/> </linker> @@ -1118,77 +1117,47 @@ <syslibset libs="Xxf86vm" /> </linker> - <linker id="linker.cfg.linux.amd64.jogl.gl2" extends="linker.cfg.linux.amd64.jogl.x11"> - <syslibset libs="GL"/> - </linker> - - <linker id="linker.cfg.linux.amd64.jogl.cg" extends="linker.cfg.linux.amd64.jogl.gl2"> - <syslibset dir="${x11.cg.lib64}" libs="Cg, CgGL"/> - </linker> - <linker id="linker.cfg.solaris.jogl.x11" extends="linker.cfg.solaris"> <syslibset libs="X11"/> </linker> - <linker id="linker.cfg.solaris.jogl.gl2" extends="linker.cfg.solaris.jogl.x11"> - <syslibset libs="GL"/> - </linker> - - <linker id="linker.cfg.solaris.jogl.cg" extends="linker.cfg.solaris.jogl.gl2"> - <syslibset dir="${x11.cg.lib32}" libs="Cg, CgGL"/> - </linker> - - <linker id="linker.cfg.solaris.sparcv9.jogl.gl2" extends="linker.cfg.solaris.sparcv9"> + <linker id="linker.cfg.solaris.sparcv9.jogl.x11" extends="linker.cfg.solaris.sparcv9"> <linkerarg value="-xarch=v9a" /> - <syslibset dir="/usr/openwin/lib/sparcv9" libs="GL"/> <syslibset dir="/usr/lib/sparcv9" libs="X11"/> </linker> - <linker id="linker.cfg.solaris.amd64.jogl.gl2" extends="linker.cfg.solaris.amd64"> + <linker id="linker.cfg.solaris.amd64.jogl.x11" extends="linker.cfg.solaris.amd64"> <linkerarg value="-xarch=amd64" /> - <syslibset dir="/usr/lib/amd64" libs="GL"/> <syslibset dir="/usr/lib/amd64" libs="X11"/> </linker> <linker id="linker.cfg.win32.mingw.jogl" extends="linker.cfg.win32.mingw"> <linkerarg value="-Wl,--kill-at" /> <!-- remove @ from function names --> - <syslibset libs="opengl32, glu32, gdi32, kernel32"/> - </linker> - - <linker id="linker.cfg.win32.mingw.jogl.cg" extends="linker.cfg.win32.mingw.jogl"> - <syslibset dir="${windows.cg.lib32}" libs="cg, cgGL"/> + <syslibset libs="gdi32, kernel32"/> </linker> <linker id="linker.cfg.win64.mingw.jogl" extends="linker.cfg.win64.mingw"> <linkerarg value="-Wl,--kill-at" /> <!-- remove @ from function names --> - <syslibset libs="opengl32, glu32, gdi32, kernel32"/> - </linker> - - <linker id="linker.cfg.win64.mingw.jogl.cg" extends="linker.cfg.win64.mingw.jogl"> - <syslibset dir="${windows.cg.lib64}" libs="cg, cgGL"/> + <syslibset libs="gdi32, kernel32"/> </linker> <linker id="linker.cfg.win32.msvc.jogl" extends="linker.cfg.win32.msvc"> - <syslibset libs="opengl32, gdi32, user32, kernel32" /> + <syslibset libs="user32, kernel32" /> <!-- This is temporary --> <syslibset libs="winmm" /> </linker> - <linker id="linker.cfg.win32.msvc.jogl.cg" extends="linker.cfg.win32.msvc.jogl"> - <syslibset dir="${windows.cg.lib32}" libs="cg, cgGL"/> - </linker> - <linker id="linker.cfg.macosx.jogl" extends="linker.cfg.macosx"> <linkerarg value="-framework" /> <linkerarg value="Cocoa" /> - <linkerarg value="-framework" /> - <linkerarg value="OpenGL" /> + <!--linkerarg value="-framework" /> + <linkerarg value="OpenGL" /--> </linker> - <linker id="linker.cfg.macosx.jogl.cg" extends="linker.cfg.macosx.jogl"> + <!--linker id="linker.cfg.macosx.jogl.cg" extends="linker.cfg.macosx.jogl"> <linkerarg value="-framework"/> <linkerarg value="Cg"/> - </linker> + </linker--> <linker id="linker.cfg.hpux.jogl" extends="linker.cfg.hpux"> <syslibset dir="/opt/graphics/OpenGL/lib" libs="GL, GLU"/> @@ -1198,83 +1167,72 @@ <target name="c.configure.win32.vc" if="isVCFamily"> <echo message="Win32.VC" /> - <property name="compiler.cfg.id" value="compiler.cfg.win32.msvc" /> - <property name="linker.cfg.id.gl2" value="linker.cfg.win32.msvc.jogl" /> - <property name="linker.cfg.id.cg" value="linker.cfg.win32.msvc.jogl.cg" /> + <property name="compiler.cfg.id" value="compiler.cfg.win32.msvc" /> + <property name="linker.cfg.id.os" value="linker.cfg.win32.msvc.jogl" /> </target> <target name="c.configure.win32.mingw" if="isMingW32"> <echo message="Win32.MingW" /> - <property name="compiler.cfg.id" value="compiler.cfg.win32.mingw" /> - <property name="linker.cfg.id.gl2" value="linker.cfg.win32.mingw.jogl" /> - <property name="linker.cfg.id.cg" value="linker.cfg.win32.mingw.jogl.cg" /> + <property name="compiler.cfg.id" value="compiler.cfg.win32.mingw" /> + <property name="linker.cfg.id.os" value="linker.cfg.win32.mingw.jogl" /> </target> <target name="c.configure.win64.mingw" if="isMingW64"> <echo message="Win64.MingW" /> - <property name="compiler.cfg.id" value="compiler.cfg.win64.mingw" /> - <property name="linker.cfg.id.gl2" value="linker.cfg.win64.mingw.jogl" /> - <property name="linker.cfg.id.cg" value="linker.cfg.win64.mingw.jogl.cg" /> + <property name="compiler.cfg.id" value="compiler.cfg.win64.mingw" /> + <property name="linker.cfg.id.os" value="linker.cfg.win64.mingw.jogl" /> </target> <target name="c.configure.linux.x86" if="isLinuxX86"> <echo message="Linux.x86" /> - <property name="compiler.cfg.id" value="compiler.cfg.linux" /> - <property name="linker.cfg.id.gl2" value="linker.cfg.linux.jogl.gl2" /> - <property name="linker.cfg.id.cg" value="linker.cfg.linux.jogl.cg" /> + <property name="compiler.cfg.id" value="compiler.cfg.linux" /> + <property name="linker.cfg.id.os" value="linker.cfg.linux.jogl.x11" /> </target> <target name="c.configure.linux.amd64" if="isLinuxAMD64"> <echo message="Linux.AMD64" /> - <property name="compiler.cfg.id" value="compiler.cfg.linux.amd64" /> - <property name="linker.cfg.id.gl2" value="linker.cfg.linux.amd64.jogl.gl2" /> - <property name="linker.cfg.id.cg" value="linker.cfg.linux.amd64.jogl.cg" /> + <property name="compiler.cfg.id" value="compiler.cfg.linux.amd64" /> + <property name="linker.cfg.id.os" value="linker.cfg.linux.amd64.jogl.x11" /> </target> <target name="c.configure.linux.ia64" if="isLinuxIA64"> <echo message="Linux.IA64" /> - <property name="compiler.cfg.id" value="compiler.cfg.linux" /> - <property name="linker.cfg.id.gl2" value="linker.cfg.linux.jogl.gl2" /> - <property name="linker.cfg.id.cg" value="linker.cfg.linux.jogl.cg" /> + <property name="compiler.cfg.id" value="compiler.cfg.linux" /> + <property name="linker.cfg.id.os" value="linker.cfg.linux.jogl.x11" /> </target> <target name="c.configure.linux" depends="c.configure.linux.x86,c.configure.linux.amd64,c.configure.linux.ia64,c.configure.x11" if="isLinux" /> <target name="c.configure.solaris32" depends="c.configure.x11" if="isSolaris32Bit"> <echo message="Solaris" /> - <property name="compiler.cfg.id" value="compiler.cfg.solaris" /> - <property name="linker.cfg.id.gl2" value="linker.cfg.solaris.jogl.gl2" /> - <property name="linker.cfg.id.cg" value="linker.cfg.solaris.jogl.cg" /> + <property name="compiler.cfg.id" value="compiler.cfg.solaris" /> + <property name="linker.cfg.id.os" value="linker.cfg.solaris.jogl.x11" /> </target> <target name="c.configure.solaris.sparcv9" depends="c.configure.x11" if="isSolarisSparcv9"> <echo message="SolarisSparcv9" /> - <property name="compiler.cfg.id" value="compiler.cfg.solaris.sparcv9" /> - <property name="linker.cfg.id.gl2" value="linker.cfg.solaris.sparcv9.jogl.gl2" /> - <property name="linker.cfg.id.cg" value="linker.cfg.solaris.sparcv9.jogl.cg" /> + <property name="compiler.cfg.id" value="compiler.cfg.solaris.sparcv9" /> + <property name="linker.cfg.id.os" value="linker.cfg.solaris.sparcv9.jogl.x11" /> </target> <target name="c.configure.solaris.amd64" depends="c.configure.x11" if="isSolarisAMD64"> <echo message="SolarisAMD64" /> - <property name="compiler.cfg.id" value="compiler.cfg.solaris.amd64" /> - <property name="linker.cfg.id.gl2" value="linker.cfg.solaris.amd64.jogl.gl2" /> - <property name="linker.cfg.id.cg" value="linker.cfg.solaris.amd64.jogl.cg" /> + <property name="compiler.cfg.id" value="compiler.cfg.solaris.amd64" /> + <property name="linker.cfg.id.os" value="linker.cfg.solaris.amd64.jogl.x11" /> </target> <target name="c.configure.freebsd" depends="c.configure.x11" if="isFreeBSD"> <echo message="FreeBSD" /> - <property name="compiler.cfg.id" value="compiler.cfg.freebsd.jogl" /> - <property name="linker.cfg.id.gl2" value="linker.cfg.linux.jogl.gl2" /> - <property name="linker.cfg.id.cg" value="linker.cfg.linux.jogl.cg" /> + <property name="compiler.cfg.id" value="compiler.cfg.freebsd.jogl" /> + <property name="linker.cfg.id.os" value="linker.cfg.linux.jogl.x11" /> </target> <target name="c.configure.hpux" depends="c.configure.x11" if="isHPUX"> <echo message="HP-UX" /> - <property name="compiler.cfg.id" value="compiler.cfg.hpux" /> - <property name="linker.cfg.id.gl2" value="linker.cfg.hpux.jogl.gl2" /> - <property name="linker.cfg.id.cg" value="linker.cfg.hpux.jogl.cg" /> + <property name="compiler.cfg.id" value="compiler.cfg.hpux" /> + <property name="linker.cfg.id.os" value="linker.cfg.hpux.jogl.x11" /> </target> <target name="c.configure.win32" depends="c.configure.win32.vc,c.configure.win32.mingw,c.configure.win64.mingw" if="isWindows" /> @@ -1282,9 +1240,8 @@ <target name="c.configure.x11" if="isX11" /> <target name="c.configure.macosx" if="isOSX"> - <property name="compiler.cfg.id" value="compiler.cfg.macosx" /> - <property name="linker.cfg.id.gl2" value="linker.cfg.macosx.jogl" /> - <property name="linker.cfg.id.cg" value="linker.cfg.macosx.jogl.cg" /> + <property name="compiler.cfg.id" value="compiler.cfg.macosx" /> + <property name="linker.cfg.id.os" value="linker.cfg.macosx.jogl" /> </target> <target name="c.configure.2" depends="c.configure.win32,c.configure.linux,c.configure.solaris32,c.configure.solaris.sparcv9,c.configure.solaris.amd64,c.configure.macosx,c.configure.freebsd,c.configure.hpux" /> @@ -1453,14 +1410,14 @@ <c.build c.compiler.src.files="c.src.files.jogl.desktop" output.lib.name="jogl_desktop" compiler.cfg.id="${compiler.cfg.id}" - linker.cfg.id="${linker.cfg.id.gl2}"/> + linker.cfg.id="${linker.cfg.id.os}"/> </target> <target name="c.build.jogl.gl2es12" unless="setup.nodesktop"> <c.build c.compiler.src.files="c.src.files.jogl.gl2es12" output.lib.name="jogl_gl2es12" compiler.cfg.id="${compiler.cfg.id}" - linker.cfg.id="${linker.cfg.id.gl2}"/> + linker.cfg.id="${linker.cfg.id.os}"/> </target> <target name="c.build.jogl.es2"> @@ -1481,7 +1438,7 @@ <c.build c.compiler.src.files="c.src.files.cg" output.lib.name="jogl_cg" compiler.cfg.id="${compiler.cfg.id}" - linker.cfg.id="${linker.cfg.id.cg}"/> + linker.cfg.id="${linker.cfg.id.os}"/> </target> <target name="c.manifest.cg" if="jogl.cg"> diff --git a/make/build-junit.xml b/make/build-junit.xml index 749e73dbd..3ec367cbb 100644 --- a/make/build-junit.xml +++ b/make/build-junit.xml @@ -53,7 +53,21 @@ <!-- - Build/run junit. --> - <target name="junit.compile" depends="init"> + <target name="junit.compile.check" depends="init"> + <property name="jogl.test.jar.path" location="${jogl.test.jar}"/> <!-- absolute path --> + <echo message="jogl.test.jar ${jogl.test.jar.path}"/> + <uptodate property="junit.compile.skip"> + <srcfiles dir= "." includes="*.xml"/> + <srcfiles dir= "${src.junit}" includes="**"/> + <srcfiles file="${nativewindow.all.jar}" /> + <srcfiles file="${jogl.all.jar}" /> + <srcfiles file="${newt.all.jar}" /> + <srcfiles file="${gluegen.jar}" /> + <mapper type="merge" to="${jogl.test.jar.path}"/> + </uptodate> + </target> + + <target name="junit.compile" depends="junit.compile.check" unless="junit.compile.skip"> <!-- Perform the junit pass Java compile --> <javac destdir="${classes}" source="${host.sourcelevel}" @@ -64,6 +78,9 @@ <classpath refid="junit_jogl_newt.compile.classpath"/> <src path="${src.junit}" /> </javac> + <delete includeEmptyDirs="true" quiet="true"> + <fileset file="${jogl.test.jar}" /> + </delete> <jar destfile="${jogl.test.jar}" filesonly="true"> <fileset dir="${classes}"> <include name="${java.part.test}"/> diff --git a/make/config/jogl/glu-CustomJavaCode-gl2.java b/make/config/jogl/glu-CustomJavaCode-gl2.java index 690e0acfa..3367b2f69 100644 --- a/make/config/jogl/glu-CustomJavaCode-gl2.java +++ b/make/config/jogl/glu-CustomJavaCode-gl2.java @@ -536,27 +536,18 @@ public final void gluEndCurve(GLUnurbs r) { // private static GLUgl2ProcAddressTable gluProcAddressTable; -private static volatile boolean gluLibraryLoaded; private static final GLUgl2ProcAddressTable getGLUProcAddressTable() { - if (!gluLibraryLoaded) { - loadGLULibrary(); - } if (gluProcAddressTable == null) { GLContext curContext = GLContext.getCurrent(); if (curContext == null) { throw new GLException("No OpenGL context current on this thread"); } + GLDynamicLookupHelper glLookupHelper = ((GLDrawableImpl) curContext.getGLDrawable()).getGLDynamicLookupHelper(); + glLookupHelper.loadGLULibrary(); GLUgl2ProcAddressTable tmp = new GLUgl2ProcAddressTable(new GLProcAddressResolver()); - tmp.reset(((GLDrawableImpl)curContext.getGLDrawable()).getDynamicLookupHelper()); + tmp.reset(glLookupHelper); gluProcAddressTable = tmp; } return gluProcAddressTable; } - -private static final synchronized void loadGLULibrary() { - if (!gluLibraryLoaded) { - GLDrawableFactoryImpl.getFactoryImpl(null).loadGLULibrary(); - gluLibraryLoaded = true; - } -} diff --git a/make/config/jogl/glu-CustomJavaCode-gl2es1.java b/make/config/jogl/glu-CustomJavaCode-gl2es1.java index eb4bcc718..d3c8ab3d1 100755 --- a/make/config/jogl/glu-CustomJavaCode-gl2es1.java +++ b/make/config/jogl/glu-CustomJavaCode-gl2es1.java @@ -225,30 +225,3 @@ public final int gluBuild3DMipmaps( int target, int internalFormat, int width, depth, format, type, buffer ) ); } -//---------------------------------------------------------------------- -// GLUProcAddressTable handling -// - -/* -private static GLUProcAddressTable gluProcAddressTable; -private static volatile boolean gluLibraryLoaded; - -private static GLUProcAddressTable getGLUProcAddressTable() { - if (!gluLibraryLoaded) { - loadGLULibrary(); - } - if (gluProcAddressTable == null) { - GLUProcAddressTable tmp = new GLUProcAddressTable(new GLProcAddressResolver()); - tmp.reset(GLDrawableFactoryImpl.getFactoryImpl()); - gluProcAddressTable = tmp; - } - return gluProcAddressTable; -} - -private static synchronized void loadGLULibrary() { - if (!gluLibraryLoaded) { - GLDrawableFactoryImpl.getFactoryImpl().loadGLULibrary(); - gluLibraryLoaded = true; - } -} -*/ diff --git a/make/config/jogl/wgl-win32.cfg b/make/config/jogl/wgl-win32.cfg index 2a69290a4..69f8c75fa 100644 --- a/make/config/jogl/wgl-win32.cfg +++ b/make/config/jogl/wgl-win32.cfg @@ -18,8 +18,6 @@ GLHeader GL/wglext.h # Implement the first argument to wglGetProcAddress as String instead # of byte[] ArgumentIsString wglGetProcAddress 0 -ArgumentIsString LoadLibraryA 0 -ArgumentIsString GetProcAddress 1 CustomCCode #define WIN32_LEAN_AND_MEAN CustomCCode #include <windows.h> diff --git a/make/config/nativewindow/x11-CustomJavaCode.java b/make/config/nativewindow/x11-CustomJavaCode.java index 6b5831215..5919ddc40 100644 --- a/make/config/nativewindow/x11-CustomJavaCode.java +++ b/make/config/nativewindow/x11-CustomJavaCode.java @@ -32,9 +32,6 @@ public static native long CreateDummyWindow(long display, int screen_index, long visualID); public static native void DestroyDummyWindow(long display, long window); - public static native long dlopen(String name); - public static native long dlsym(String name); - public static native int XCloseDisplay(long display); public static native void XUnlockDisplay(long display); public static native void XLockDisplay(long display); diff --git a/make/scripts/java-run-all.sh b/make/scripts/java-run-all.sh index 5f6cff28a..622ed1bae 100755 --- a/make/scripts/java-run-all.sh +++ b/make/scripts/java-run-all.sh @@ -31,6 +31,7 @@ shift MOSX=0 uname -a | grep -i Darwin && MOSX=1 +D_ARGS="-Dgluegen.debug.ProcAddressHelper=true -Dgluegen.debug.NativeLibrary=true -Djogl.debug=all" # D_ARGS="-Dgluegen.debug.ProcAddressHelper=true -Dgluegen.debug.NativeLibrary=true -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" # D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all -Djogl.debug.GLSLState" # D_ARGS="-Dnativewindow.debug.X11Util=true -Djogl.debug.GLDrawableFactory=true" diff --git a/make/scripts/make.jogl.all.linux-x86.sh b/make/scripts/make.jogl.all.linux-x86.sh index 7b08ae5e8..5033f5f3a 100644 --- a/make/scripts/make.jogl.all.linux-x86.sh +++ b/make/scripts/make.jogl.all.linux-x86.sh @@ -39,8 +39,8 @@ fi # -DisX11=true \ # -Djogl.cg=1 -Dx11.cg.lib=../../lib-linux-x86 \ -LD_PRELOAD=$J2RE_HOME/lib/i386/libjsig.so -export LD_PRELOAD +#LD_LIBRARY_PATH=/opt-linux-x86_64/mesa-7.8.1/lib64 +#export LD_LIBRARY_PATH ant \ $CUSTOMLIBDIR \ diff --git a/make/scripts/make.jogl.all.linux-x86_64.sh b/make/scripts/make.jogl.all.linux-x86_64.sh index 45777998c..b17cd2f15 100644 --- a/make/scripts/make.jogl.all.linux-x86_64.sh +++ b/make/scripts/make.jogl.all.linux-x86_64.sh @@ -41,9 +41,6 @@ fi #LD_LIBRARY_PATH=/opt-linux-x86_64/mesa-7.8.1/lib64 #export LD_LIBRARY_PATH -LD_PRELOAD=$J2RE_HOME/lib/amd64/libjsig.so -export LD_PRELOAD - ant \ $CUSTOMLIBDIR \ -Dbuild.noarchives=true \ diff --git a/make/stub_includes/win32/wingdi.h b/make/stub_includes/win32/wingdi.h index fbf2ec5ec..a0a4194b5 100644 --- a/make/stub_includes/win32/wingdi.h +++ b/make/stub_includes/win32/wingdi.h @@ -172,8 +172,6 @@ typedef struct tagPIXELFORMATDESCRIPTOR // Windows routines WINBASEAPI DWORD WINAPI GetLastError(VOID); -WINBASEAPI HMODULE WINAPI LoadLibraryA(LPCSTR lpLibFileName); -WINBASEAPI PROC WINAPI GetProcAddress(HMODULE hModule, LPCSTR lpProcName); // OpenGL-related routines WINGDIAPI int WINAPI ChoosePixelFormat(HDC, CONST PIXELFORMATDESCRIPTOR *); 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); + } +} + + diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index d746101ca..88eac0a92 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -37,9 +37,11 @@ package javax.media.opengl; import com.jogamp.common.util.*; -import com.jogamp.opengl.impl.DRIHack; import com.jogamp.opengl.impl.Debug; import com.jogamp.opengl.impl.GLJNILibLoader; +import com.jogamp.opengl.impl.GLDrawableFactoryImpl; +import com.jogamp.opengl.impl.egl.EGLDynamicLookupHelper; +import com.jogamp.opengl.impl.DesktopGLDynamicLookupHelper; import com.jogamp.common.jvm.JVMUtil; import java.util.HashMap; import java.util.Iterator; @@ -865,95 +867,53 @@ public class GLProfile implements Cloneable { isAWTAvailable = NativeWindowFactory.isAWTAvailable() && ReflectionUtil.isClassAvailable("javax.media.opengl.awt.GLCanvas") ; // JOGL - boolean hasDesktopGL = false; - boolean hasDesktopGLES12 = false; - boolean hasNativeOSFactory = false; - Throwable t; - - // - // First iteration of desktop GL availability detection - // - native libs exist - // - class exists - // - t=null; - try { - // See DRIHack.java for an explanation of why this is necessary - DRIHack.begin(); - GLJNILibLoader.loadGLDesktop(); - DRIHack.end(); - hasDesktopGL = true; - } catch (UnsatisfiedLinkError ule) { - t=ule; - } catch (SecurityException se) { - t=se; - } catch (NullPointerException npe) { - t=npe; - } catch (RuntimeException re) { - t=re; - } - if(null!=t) { - if (DEBUG) { - System.err.println("GLProfile.static Desktop GL Library not available"); - t.printStackTrace(); - } - } - - t=null; - try { - // See DRIHack.java for an explanation of why this is necessary - DRIHack.begin(); - GLJNILibLoader.loadGLDesktopES12(); - DRIHack.end(); - hasDesktopGLES12 = 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("GLProfile.static Desktop GLES12 Library not available"); - t.printStackTrace(); - } - - - hasGL234Impl = hasDesktopGL && ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.gl4.GL4bcImpl"); + hasGL234Impl = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.gl4.GL4bcImpl"); hasGL4bcImpl = hasGL234Impl; hasGL4Impl = hasGL234Impl; hasGL3bcImpl = hasGL234Impl; hasGL3Impl = hasGL234Impl; hasGL2Impl = hasGL234Impl; - hasGL2ES12Impl = hasDesktopGLES12 && ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.gl2es12.GL2ES12Impl"); + hasGL2ES12Impl = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.gl2es12.GL2ES12Impl"); mappedProfiles = computeProfileMap(); + boolean hasDesktopGL = false; + boolean hasDesktopGLES12 = false; + boolean hasNativeOSFactory = false; + Throwable t; + // - // Second iteration of desktop GL availability detection + // Iteration of desktop GL availability detection // utilizing the detected GL version in the shared context. // // - Instantiate GLDrawableFactory incl its shared dummy drawable/context, // which will register at GLContext .. // - if(hasDesktopGL||hasDesktopGLES12) { - t=null; - // if successfull it has a shared dummy drawable and context created - try { - hasNativeOSFactory = null != GLDrawableFactory.getFactoryImpl(GL2); - } catch (LinkageError le) { - t=le; - } catch (RuntimeException re) { - t=re; + t=null; + // if successfull it has a shared dummy drawable and context created + try { + GLDrawableFactoryImpl factory = (GLDrawableFactoryImpl) GLDrawableFactory.getFactoryImpl(GL2); + hasNativeOSFactory = null != factory; + if(hasNativeOSFactory) { + DesktopGLDynamicLookupHelper deskGLLookupHelper = (DesktopGLDynamicLookupHelper) factory.getGLDynamicLookupHelper(0); + hasDesktopGL = deskGLLookupHelper.hasGLBinding(); + hasDesktopGLES12 = deskGLLookupHelper.hasGLES12Binding(); } - if(DEBUG && null!=t) { - System.err.println("GLProfile.static - Native platform GLDrawable factory not available"); + } catch (LinkageError le) { + t=le; + } catch (RuntimeException re) { + t=re; + } + if(DEBUG) { + if(null!=t) { t.printStackTrace(); } + if(!hasNativeOSFactory) { + System.err.println("GLProfile.static - Native platform GLDrawable factory not available"); + } } - if(hasNativeOSFactory && !GLContext.mappedVersionsAvailableSet) { + if(hasDesktopGL && !GLContext.mappedVersionsAvailableSet) { // nobody yet set the available desktop versions, see {@link GLContextImpl#makeCurrent}, // so we have to add the usual suspect GLContext.mapVersionAvailable(2, GLContext.CTX_PROFILE_COMPAT, 1, 5, GLContext.CTX_PROFILE_COMPAT|GLContext.CTX_OPTION_ANY); @@ -977,16 +937,20 @@ public class GLProfile implements Cloneable { hasGL2ES12Impl = hasGL2ES12Impl && GLContext.isGL2Available(); } - boolean hasEGLDynLookup = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.egl.EGLDynamicLookupHelper"); - boolean hasEGLDrawableFactory = false; - boolean btest = false; - if(hasEGLDynLookup) { + if ( ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.egl.EGLDynamicLookupHelper") ) { t=null; try { - hasEGLDrawableFactory = null!=GLDrawableFactory.getFactoryImpl(GLES2); - btest = hasEGLDrawableFactory && - ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.es2.GLES2Impl") && - null!=com.jogamp.opengl.impl.egl.EGLDynamicLookupHelper.getDynamicLookupHelper(2); + GLDrawableFactoryImpl factory = (GLDrawableFactoryImpl) GLDrawableFactory.getFactoryImpl(GLES2); + if(null != factory) { + EGLDynamicLookupHelper eglLookupHelper = (EGLDynamicLookupHelper) factory.getGLDynamicLookupHelper(2); + if(null!=eglLookupHelper) { + hasGLES2Impl = eglLookupHelper.hasESBinding(); + } + eglLookupHelper = (EGLDynamicLookupHelper) factory.getGLDynamicLookupHelper(1); + if(null!=eglLookupHelper) { + hasGLES1Impl = eglLookupHelper.hasESBinding(); + } + } } catch (LinkageError le) { t=le; } catch (SecurityException se) { @@ -997,37 +961,12 @@ public class GLProfile implements Cloneable { t=re; } if(DEBUG && null!=t) { - System.err.println("GLProfile.static - GL ES2 Factory/Library not available"); t.printStackTrace(); } } - hasGLES2Impl = btest; if(hasGLES2Impl) { GLContext.mapVersionAvailable(2, GLContext.CTX_PROFILE_ES, 2, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_OPTION_ANY); } - - btest = false; - if(hasEGLDynLookup) { - t=null; - try { - btest = hasEGLDrawableFactory && - ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.es1.GLES1Impl") && - null!=com.jogamp.opengl.impl.egl.EGLDynamicLookupHelper.getDynamicLookupHelper(1); - } catch (LinkageError le) { - t=le; - } catch (SecurityException se) { - t=se; - } catch (NullPointerException npe) { - t=npe; - } catch (RuntimeException re) { - t=re; - } - if(DEBUG && null!=t) { - System.err.println("GLProfile.static - GL ES1 Factory/Library not available"); - t.printStackTrace(); - } - } - hasGLES1Impl = btest; if(hasGLES1Impl) { GLContext.mapVersionAvailable(1, GLContext.CTX_PROFILE_ES, 1, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_OPTION_ANY); } @@ -1039,8 +978,6 @@ public class GLProfile implements Cloneable { System.err.println("GLProfile.static hasNativeOSFactory "+hasNativeOSFactory); System.err.println("GLProfile.static hasDesktopGL "+hasDesktopGL); System.err.println("GLProfile.static hasDesktopGLES12 "+hasDesktopGLES12); - System.err.println("GLProfile.static hasEGLDynLookup "+hasEGLDynLookup); - System.err.println("GLProfile.static hasEGLDrawableFactory "+hasEGLDrawableFactory); System.err.println("GLProfile.static hasGL234Impl "+hasGL234Impl); System.err.println("GLProfile.static "+glAvailabilityToString()); } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 9932f0cf9..be42e1da1 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -320,11 +320,13 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable { // The user really should not be invoking remove() from this // thread -- but since he/she is, we can not go over to the // EDT at this point. Try to destroy the context from here. - drawableHelper.invokeGL(drawable, context, disposeAction, null); - } else { + if(context.isCreated()) { + drawableHelper.invokeGL(drawable, context, disposeAction, null); + } + } else if(context.isCreated()) { Threading.invokeOnOpenGLThread(disposeOnEventDispatchThreadAction); } - } else { + } else if(context.isCreated()) { drawableHelper.invokeGL(drawable, context, disposeAction, null); } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index eb8c68263..61e1429b6 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -227,11 +227,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable { // The user really should not be invoking remove() from this // thread -- but since he/she is, we can not go over to the // EDT at this point. Try to destroy the context from here. - drawableHelper.invokeGL(disposeDrawable, disposeContext, disposeAction, null); - } else { + if(disposeContext.isCreated()) { + drawableHelper.invokeGL(disposeDrawable, disposeContext, disposeAction, null); + } + } else if(disposeContext.isCreated()) { Threading.invokeOnOpenGLThread(disposeOnEventDispatchThreadAction); } - } else { + } else if(disposeContext.isCreated()) { drawableHelper.invokeGL(disposeDrawable, disposeContext, disposeAction, null); } diff --git a/src/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c index 23ff5f854..778959a31 100644 --- a/src/nativewindow/native/x11/Xmisc.c +++ b/src/nativewindow/native/x11/Xmisc.c @@ -266,26 +266,6 @@ Java_com_jogamp_nativewindow_impl_x11_X11Util_initialize(JNIEnv *env, jclass _un } } -JNIEXPORT jlong JNICALL -Java_com_jogamp_nativewindow_impl_x11_X11Lib_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_jogamp_nativewindow_impl_x11_X11Lib_dlsym(JNIEnv *env, jclass _unused, jstring name) { - const jbyte* chars; - void* res; - chars = (*env)->GetStringUTFChars(env, name, NULL); - res = dlsym(RTLD_DEFAULT, chars); - (*env)->ReleaseStringUTFChars(env, name, chars); - return (jlong) ((intptr_t) res); -} - /* Java->C glue code: * Java package: com.jogamp.nativewindow.impl.x11.X11Lib * Java method: XVisualInfo XGetVisualInfo(long arg0, long arg1, XVisualInfo arg2, java.nio.IntBuffer arg3) diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 9559043c4..dec41b427 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -167,7 +167,7 @@ public class GLWindow extends Window implements GLAutoDrawable { e1.printStackTrace(); } - if ( null != context && null != drawable && drawable.isRealized() ) { + if ( null != context && context.isCreated() && null != drawable && drawable.isRealized() ) { helper.invokeGL(drawable, context, disposeAction, null); } |