diff options
author | Sven Gothel <[email protected]> | 2010-06-04 05:21:32 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-06-04 05:21:32 +0200 |
commit | 4512900ddcb9ce9a498411d257b1b6d6010ec006 (patch) | |
tree | ae9878c82cda41920f46ea639178f7d951d5af8f /src/jogl/classes/com/jogamp/opengl/impl/macosx | |
parent | 6bbf70d2f4a06b8aa0b100d83ed9aca6dd80040e (diff) |
JOGL: Unify library loading (impl and binding), incl. lookup ; GLAutoDrawable: dispose() calls only with created context.
- Using the EGL approach of DynamicLookupHelper,
now generalized in abstract GLDynamicLookupHelper,
DesktopGLDynamicLookupHelper and EGLGLDynamicLookupHelper.
The implementation of these are self contained.
- Sharing common code.
- Unifying implementation and binding loading,
as well as the function lookup within the impl libs.
- Removed DRIHack, since its no more required
due to the new DesktopGLDynamicLookupHelper.
- Removed compile time link to GL and GLU libs
- Removed redundant library OS functions from X11/WGL
bindings, GlueGen's common code is being used now.
- GLAutoDrawable: dispose() calls only with created context.
This cleans up stack traces in case of eventual bugs,
where context creation is not successful.
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/impl/macosx')
3 files changed, 103 insertions, 13 deletions
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 + } +} + |