Bugzilla – Attachment 61 Details for
Bug 172
Automatically load the .lib/.so files rather than count on -Djava.library.path
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
Log In
[x]
|
Forgot Password
Login:
[x]
Proposed implementation of the enhancement
OpenGL.java (text/plain), 3.33 KB, created by
Sven Gothel
on 2005-08-02 10:28:00 CEST
(
hide
)
Description:
Proposed implementation of the enhancement
Filename:
MIME Type:
Creator:
Sven Gothel
Created:
2005-08-02 10:28:00 CEST
Size:
3.33 KB
patch
obsolete
>/* > * OpenGL.java > * > * Created on August 2, 2005, 2:05 AM > */ > >package org.slage.ui; >import java.io.*; >import java.net.*; >import org.slage.Tools; > >/** > * Wrapper for basic OpenGL loading stuff just to clean it up out of SLAGE.java > * @author Jaeden > */ >public abstract class OpenGL >{ > > /** Creates a new instance of OpenGL */ > private OpenGL() {} > > > /** If 'true', we want to load Cg support. > * This would normally be on all the time, but JOGL's linking to it is a bit behind the times. > * JOGL needs to update every time Cg does, or the .DLL won't properly load. As we're not planning > * on using Cg in SLAGE at this time, we'll leave it disabled by default. */ > private static boolean bLoadCg = false; > > > /** Static initialization - load libraries */ > /** Ensure we load GL on startup. This is a replacement for the command-line switches > * -Djava.library.path=. and -cp .;jogl.jar. > * > * > */ > public static void loadOpenGL() > { > // workaround to allow our loader to do its job > // see http://192.18.37.44/forums/index.php?topic=10262.0;topicseen > net.java.games.jogl.impl.NativeLibLoader.disableLoading(); > > // Manually load AWT to work around the problem with error boxes coming up claiming it's not found. > // Apparently AWT has to be loaded -before- jogl's .dll files or all Hell breaks loose. > java.awt.Toolkit.getDefaultToolkit(); > System.loadLibrary("jawt"); > > // load in the JOGL.jar file > try > { > URL urlJOGL = (new File(Tools.GetRelativePath(null) + Tools.GetFileSeparator() + "jogl.jar")).toURL(); > URL[] urls = { urlJOGL }; > URLClassLoader classLoader = new URLClassLoader(urls); > } > catch (MalformedURLException exc) > { > // TODO: Log > System.err.println("MalformedURLException while loading jogl.jar"); > } > > // Now, load the .dll/.so files for the OpenGL C bindings > String strOS = Tools.GetOS(); > String strJOGL = Tools.GetRelativePath("lib") + Tools.GetFileSeparator(); > > if (strOS.startsWith("Windows")) > { > System.load(strJOGL + "jogl.dll"); > > if (bLoadCg) > System.load(strJOGL + "jogl_cg.dll"); > } > if (strOS.startsWith("Mac OS")) > { > System.load(strJOGL + "libjogl.jnlib"); > if (bLoadCg) > System.load(strJOGL + "libjogl_cg.jnlib"); > } > if (strOS.startsWith("Linux")) > { > System.load(strJOGL + "libjogl.so"); > if (bLoadCg) > System.load(strJOGL + "libjogl_cg.so"); > } > if (strOS.startsWith("Solaris")) > { > String strArch = System.getProperty("os.arch"); > if (strArch.equalsIgnoreCase("sparc")) > { > System.load(strJOGL + "libjogl_solsparc.so"); > } > if (strArch.equalsIgnoreCase("x86")) > { > System.load(strJOGL + "libjogl_solx86.so"); > } > } > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 172
: 61