diff --git a/src/java/org/lwjgl/devil/IL.java b/src/java/org/lwjgl/devil/IL.java index b375699c..a5e13a43 100644 --- a/src/java/org/lwjgl/devil/IL.java +++ b/src/java/org/lwjgl/devil/IL.java @@ -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(); } diff --git a/src/java/org/lwjgl/devil/ILU.java b/src/java/org/lwjgl/devil/ILU.java index 9727ff00..aaefda87 100644 --- a/src/java/org/lwjgl/devil/ILU.java +++ b/src/java/org/lwjgl/devil/ILU.java @@ -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; + } } diff --git a/src/java/org/lwjgl/devil/ILUT.java b/src/java/org/lwjgl/devil/ILUT.java index 38e4afe9..28c69dcc 100644 --- a/src/java/org/lwjgl/devil/ILUT.java +++ b/src/java/org/lwjgl/devil/ILUT.java @@ -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; + } }