first stab at one-shot devil initialization on mac

This commit is contained in:
Brian Matzon 2005-03-28 13:08:48 +00:00
parent 97f919869e
commit 3dc9e4e4cf
3 changed files with 69 additions and 7 deletions

View File

@ -596,6 +596,16 @@ public class IL {
try {
IL.initNativeStubs();
IL.ilInit();
// We need to initialize everything in one fell swoop on mac
if(System.getProperty("os.name").startsWith("Mac")) {
ILU.initNativeStubs();
ILU.setCreated(true);
ILUT.initNativeStubs();
ILUT.setCreated(true);
}
created = true;
} catch (LWJGLException e) {
destroy();
@ -608,6 +618,18 @@ public class IL {
*/
public static void destroy() {
resetNativeStubs(IL.class);
// We need to destroy everything on mac in one go
if(System.getProperty("os.name").startsWith("Mac")) {
ILU.resetNativeStubs(ILU.class);
ILU.nDestroy();
ILU.setCreated(false);
ILUT.resetNativeStubs(ILUT.class);
ILUT.nDestroy();
ILUT.setCreated(false);
}
if (created) {
nDestroy();
}

View File

@ -169,7 +169,12 @@ public class ILU {
if(!IL.isCreated()) {
throw new LWJGLException("Cannot create ILU without having created IL instance");
}
// We need to do nothing when running on mac, since all is loaded in IL
if(System.getProperty("os.name").startsWith("Mac")) {
return;
}
String[] iluPaths = LWJGLUtil.getLibraryPaths(new String[]{
"ILU", "ILU.dll",
"ILU", "libILU.so",
@ -187,14 +192,20 @@ public class ILU {
}
}
private static native void initNativeStubs() throws LWJGLException;
static native void initNativeStubs() throws LWJGLException;
private static native void resetNativeStubs(Class clazz);
static native void resetNativeStubs(Class clazz);
/**
* Exit cleanly by calling destroy.
*/
public static void destroy() {
// We need to do nothing when running on mac, since all is destroyed in IL
if(System.getProperty("os.name").startsWith("Mac")) {
return;
}
resetNativeStubs(ILU.class);
if (created) {
nDestroy();
@ -212,5 +223,14 @@ public class ILU {
/**
* Native method the destroy the ILU
*/
protected static native void nDestroy();
static native void nDestroy();
/**
* Forcefully set created. Used internally by mac platform since
* it loads ilu/ilut in IL and needs to mark them as created
* @param created value to set created to
*/
static void setCreated(boolean created) {
ILU.created = created;
}
}

View File

@ -133,7 +133,12 @@ public class ILUT {
if(!IL.isCreated()) {
throw new LWJGLException("Cannot create ILUT without having created IL instance");
}
// We need to do nothing when running on mac, since all is loaded in IL
if(System.getProperty("os.name").startsWith("Mac")) {
return;
}
String[] ilutPaths = LWJGLUtil.getLibraryPaths(new String[]{
"ILUT", "ILUT.dll",
"ILUT", "libILUT.so",
@ -151,14 +156,20 @@ public class ILUT {
}
}
private static native void initNativeStubs() throws LWJGLException;
static native void initNativeStubs() throws LWJGLException;
private static native void resetNativeStubs(Class clazz);
static native void resetNativeStubs(Class clazz);
/**
* Exit cleanly by calling destroy.
*/
public static void destroy() {
// We need to do nothing when running on mac, since all is destroyed in IL
if(System.getProperty("os.name").startsWith("Mac")) {
return;
}
resetNativeStubs(ILUT.class);
if (created) {
nDestroy();
@ -177,4 +188,13 @@ public class ILUT {
* Native method the destroy the ILUT
*/
protected static native void nDestroy();
/**
* Forcefully set created. Used internally by mac platform since
* it loads ilu/ilut in IL and needs to mark them as created
* @param created value to set created to
*/
static void setCreated(boolean created) {
ILUT.created = created;
}
}