mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-06 06:53:59 +00:00
reworked devil dynamic stub to use generated header using a new ILNative class
This commit is contained in:
parent
a9bd41f12e
commit
20a9d2216c
14 changed files with 213 additions and 336 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2004 LWJGL Project
|
||||
* Copyright (c) 2002-2005 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -41,7 +41,6 @@ import java.nio.IntBuffer;
|
|||
|
||||
import org.lwjgl.BufferChecks;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.LWJGLUtil;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
|
|
@ -295,9 +294,6 @@ public class IL {
|
|||
public static final int IL_SEEK_END = 2;
|
||||
public static final int IL_EOF = -1;
|
||||
|
||||
/** Have we been created? */
|
||||
protected static boolean created;
|
||||
|
||||
public static native boolean ilActiveImage(int Number);
|
||||
public static native boolean ilActiveLayer(int Number);
|
||||
public static native boolean ilActiveMipmap(int Number);
|
||||
|
|
@ -362,7 +358,7 @@ public class IL {
|
|||
public static native ByteBuffer ilGetPalette();
|
||||
public static native String ilGetString(int StringName);
|
||||
public static native void ilHint(int Target, int Mode);
|
||||
private static native void ilInit();
|
||||
static native void ilInit();
|
||||
public static native boolean ilIsDisabled(int Mode);
|
||||
public static native boolean ilIsEnabled(int Mode);
|
||||
public static native boolean ilIsImage(int Image);
|
||||
|
|
@ -573,41 +569,9 @@ public class IL {
|
|||
return result;
|
||||
}
|
||||
|
||||
// public static native int ilGetDXTCData(ILvoid *Buffer, int BufferSize, int DXTCFormat);
|
||||
// public static native boolean ilIsValidF(int Type, ILHANDLE File);
|
||||
// public static native boolean ilLoadF(int Type, ILHANDLE File);
|
||||
// public static native boolean ilLoadDataF(ILHANDLE File, int Width, int Height, int Depth, ILubyte Bpp);
|
||||
// public static native int ilSaveF(int Type, ILHANDLE File);
|
||||
// public static native void ilRegisterFormat(int Format);
|
||||
// public static native boolean ilRegisterLoad(String Ext, IL_LOADPROC Load);
|
||||
// public static native boolean ilRegisterMipNum(int Num);
|
||||
// public static native boolean ilRegisterNumImages(int Num);
|
||||
// public static native void ilRegisterOrigin(int Origin);
|
||||
// public static void ilRegisterPal(ByteBuffer Pal, int Size, int Type);
|
||||
// public static native void nilRegisterPal(ByteBuffer Pal, int pal_position, int Size, int Type);
|
||||
// public static native boolean ilRegisterSave(String Ext, IL_SAVEPROC Save);
|
||||
// public static native void ilRegisterType(int Type);
|
||||
// public static native void ilSetMemory(mAlloc, mFree);
|
||||
// public static native void ilSetRead(fOpenRProc, fCloseRProc, fEofProc, fGetcProc, fReadProc, fSeekRProc, fTellRProc);
|
||||
// public static native void ilSetWrite(fOpenWProc, fCloseWProc, fPutcProc, fSeekWProc, fTellWProc, fWriteProc);
|
||||
|
||||
|
||||
static {
|
||||
System.loadLibrary("lwjgl-devil");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return true if DevIL has been created
|
||||
*/
|
||||
public static boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
private static native void initNativeStubs() throws LWJGLException;
|
||||
|
||||
private static native void resetNativeStubs(Class clazz);
|
||||
|
||||
/** Have we been created? */
|
||||
protected static boolean created;
|
||||
|
||||
/**
|
||||
* Creates a new instance of IL.
|
||||
*/
|
||||
|
|
@ -616,43 +580,24 @@ public class IL {
|
|||
return;
|
||||
}
|
||||
|
||||
String[] illPaths = LWJGLUtil.getLibraryPaths(new String[]{
|
||||
"DevIL", "DevIL.dll",
|
||||
"IL", "libIL.so",
|
||||
"IL", "libIL.dylib"}, IL.class.getClassLoader());
|
||||
nCreate(illPaths);
|
||||
|
||||
try {
|
||||
IL.initNativeStubs();
|
||||
IL.ilInit();
|
||||
created = true;
|
||||
} catch (LWJGLException e) {
|
||||
destroy();
|
||||
throw e;
|
||||
}
|
||||
ILNative.createIL();
|
||||
created = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exit cleanly by calling destroy.
|
||||
*/
|
||||
public static void destroy() {
|
||||
resetNativeStubs(IL.class);
|
||||
|
||||
if (created) {
|
||||
nDestroy();
|
||||
ILNative.destroyIL();
|
||||
created = false;
|
||||
}
|
||||
created = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Native method to create IL instance
|
||||
*
|
||||
* @param ilPaths Array of strings containing paths to search for Devil library
|
||||
* @return true if DevIL has been created
|
||||
*/
|
||||
protected static native void nCreate(String[] ilPaths) throws LWJGLException;
|
||||
|
||||
/**
|
||||
* Native method the destroy the IL
|
||||
*/
|
||||
protected static native void nDestroy();
|
||||
public static boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
139
src/java/org/lwjgl/devil/ILNative.java
Normal file
139
src/java/org/lwjgl/devil/ILNative.java
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2005 LWJGL Project
|
||||
* 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 'LWJGL' 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 THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS 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 org.lwjgl.devil;
|
||||
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.LWJGLUtil;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
* <p>
|
||||
* Native interface for DevIL
|
||||
* </p>
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
*/
|
||||
class ILNative {
|
||||
|
||||
static {
|
||||
System.loadLibrary("lwjgl-devil");
|
||||
}
|
||||
|
||||
// IL
|
||||
// ===========================================================
|
||||
static native void initNativeStubsIL(Class clazz) throws LWJGLException;
|
||||
static native void resetNativeStubsIL(Class clazz);
|
||||
static native void nCreateIL(String[] ilPaths) throws LWJGLException;
|
||||
static native void nDestroyIL();
|
||||
|
||||
static void createIL() throws LWJGLException {
|
||||
String[] illPaths = LWJGLUtil.getLibraryPaths(new String[]{
|
||||
"DevIL", "DevIL.dll",
|
||||
"IL", "libIL.so",
|
||||
"IL", "libIL.dylib"}, IL.class.getClassLoader());
|
||||
ILNative.nCreateIL(illPaths);
|
||||
|
||||
try {
|
||||
ILNative.initNativeStubsIL(IL.class);
|
||||
IL.ilInit();
|
||||
} catch (LWJGLException e) {
|
||||
IL.destroy();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public static void destroyIL() {
|
||||
ILNative.resetNativeStubsIL(IL.class);
|
||||
ILNative.nDestroyIL();
|
||||
}
|
||||
// -----------------------------------------------------------
|
||||
|
||||
|
||||
// ILU
|
||||
// ===========================================================
|
||||
static native void initNativeStubsILU(Class clazz) throws LWJGLException;
|
||||
static native void resetNativeStubsILU(Class clazz);
|
||||
static native void nCreateILU(String[] iluPaths) throws LWJGLException;
|
||||
static native void nDestroyILU();
|
||||
|
||||
static void createILU() throws LWJGLException {
|
||||
String[] iluPaths = LWJGLUtil.getLibraryPaths(new String[]{
|
||||
"ILU", "ILU.dll",
|
||||
"ILU", "libILU.so",
|
||||
"ILU", "libILU.dylib"}, ILU.class.getClassLoader());
|
||||
ILNative.nCreateILU(iluPaths);
|
||||
|
||||
try {
|
||||
ILNative.initNativeStubsILU(ILU.class);
|
||||
ILU.iluInit();
|
||||
} catch (LWJGLException e) {
|
||||
ILU.destroy();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public static void destroyILU() {
|
||||
ILNative.resetNativeStubsILU(ILU.class);
|
||||
ILNative.nDestroyILU();
|
||||
}
|
||||
// -----------------------------------------------------------
|
||||
|
||||
// ILU
|
||||
// ===========================================================
|
||||
static native void initNativeStubsILUT(Class clazz) throws LWJGLException;
|
||||
static native void resetNativeStubsILUT(Class clazz);
|
||||
static native void nCreateILUT(String[] ilutPaths) throws LWJGLException;
|
||||
static native void nDestroyILUT();
|
||||
|
||||
static void createILUT() throws LWJGLException {
|
||||
String[] ilutPaths = LWJGLUtil.getLibraryPaths(new String[]{
|
||||
"ILUT", "ILUT.dll",
|
||||
"ILUT", "libILUT.so",
|
||||
"ILUT", "libILUT.dylib"}, ILUT.class.getClassLoader());
|
||||
ILNative.nCreateILUT(ilutPaths);
|
||||
|
||||
try {
|
||||
ILNative.initNativeStubsILUT(ILUT.class);
|
||||
ILUT.ilutInit();
|
||||
} catch (LWJGLException e) {
|
||||
ILUT.destroy();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public static void destroyILUT() {
|
||||
ILNative.resetNativeStubsILUT(ILUT.class);
|
||||
ILNative.nDestroyILUT();
|
||||
}
|
||||
// -----------------------------------------------------------
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2004 LWJGL Project
|
||||
* Copyright (c) 2002-2005 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -35,7 +35,6 @@ import java.nio.IntBuffer;
|
|||
|
||||
import org.lwjgl.BufferChecks;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.LWJGLUtil;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
|
|
@ -79,16 +78,6 @@ public class ILU {
|
|||
public static final int ILU_VERSION_NUM = IL.IL_VERSION_NUM;
|
||||
public static final int ILU_VENDOR = IL.IL_VENDOR;
|
||||
|
||||
/** Have we been created? */
|
||||
protected static boolean created;
|
||||
|
||||
/**
|
||||
* @return true if ILU has been created
|
||||
*/
|
||||
public static boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public static native boolean iluAlienify();
|
||||
public static native boolean iluBlurAvg(int iter);
|
||||
public static native boolean iluBlurGaussian(int iter);
|
||||
|
|
@ -118,7 +107,7 @@ public class ILU {
|
|||
private static native void niluGetIntegerv(int mode, IntBuffer param, int param_offset);
|
||||
public static native String iluGetString(int stringName);
|
||||
public static native void iluImageParameter(int pName, int param);
|
||||
private static native void iluInit();
|
||||
static native void iluInit();
|
||||
public static native boolean iluInvertAlpha();
|
||||
public static native int iluLoadImage(String fileName);
|
||||
public static native boolean iluMirror();
|
||||
|
|
@ -154,6 +143,9 @@ public class ILU {
|
|||
iluScaleColours(r, g, b);
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/** Have we been created? */
|
||||
protected static boolean created;
|
||||
|
||||
/**
|
||||
* Creates a new instance of ILU. Cannot be created unless IL has been created.
|
||||
|
|
@ -163,55 +155,24 @@ public class ILU {
|
|||
throw new LWJGLException("Cannot create ILU without having created IL instance");
|
||||
}
|
||||
|
||||
String[] iluPaths = LWJGLUtil.getLibraryPaths(new String[]{
|
||||
"ILU", "ILU.dll",
|
||||
"ILU", "libILU.so",
|
||||
"ILU", "libILU.dylib"}, ILU.class.getClassLoader());
|
||||
nCreate(iluPaths);
|
||||
|
||||
try {
|
||||
ILU.initNativeStubs();
|
||||
ILU.iluInit();
|
||||
created = true;
|
||||
} catch (LWJGLException e) {
|
||||
destroy();
|
||||
throw e;
|
||||
}
|
||||
ILNative.createILU();
|
||||
created = true;
|
||||
}
|
||||
|
||||
static native void initNativeStubs() throws LWJGLException;
|
||||
|
||||
static native void resetNativeStubs(Class clazz);
|
||||
|
||||
/**
|
||||
* Exit cleanly by calling destroy.
|
||||
*/
|
||||
public static void destroy() {
|
||||
resetNativeStubs(ILU.class);
|
||||
if (created) {
|
||||
nDestroy();
|
||||
ILNative.destroyILU();
|
||||
created = false;
|
||||
}
|
||||
created = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Native method to create ILU instance
|
||||
*
|
||||
* @param iluPaths Array of strings containing paths to search for ILU library
|
||||
* @return true if ILU has been created
|
||||
*/
|
||||
protected static native void nCreate(String[] iluPaths) throws LWJGLException;
|
||||
|
||||
/**
|
||||
* Native method the destroy the ILU
|
||||
*/
|
||||
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;
|
||||
}
|
||||
public static boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2004 LWJGL Project
|
||||
* Copyright (c) 2002-2005 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -35,7 +35,6 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.IntBuffer;
|
||||
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.LWJGLUtil;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
|
|
@ -83,9 +82,6 @@ public class ILUT {
|
|||
public static final int ILUT_VENDOR = IL.IL_VENDOR;
|
||||
public static final int ILUT_VERSION_NUM = IL.IL_VERSION_NUM;
|
||||
|
||||
/** Have we been created? */
|
||||
protected static boolean created;
|
||||
|
||||
public static native boolean ilutRenderer(int renderer);
|
||||
public static native boolean ilutDisable(int mode);
|
||||
public static native boolean ilutEnable(int mode);
|
||||
|
|
@ -94,7 +90,7 @@ public class ILUT {
|
|||
public static native void ilutGetBooleanv(int mode, ByteBuffer param);
|
||||
public static native void ilutGetIntegerv(int mode, IntBuffer Param);
|
||||
public static native String ilutGetString(int stringName);
|
||||
private static native void ilutInit();
|
||||
static native void ilutInit();
|
||||
public static native boolean ilutIsDisabled(int mode);
|
||||
public static native boolean ilutIsEnabled(int mode);
|
||||
public static native void ilutPopAttrib();
|
||||
|
|
@ -112,13 +108,9 @@ public class ILUT {
|
|||
public static native boolean ilutGLSaveImage(String fileName, int texID);
|
||||
public static native boolean ilutGLSetTex(int texID);
|
||||
public static native boolean ilutGLTexImage(int level);
|
||||
|
||||
/**
|
||||
* @return true if ILUT has been created
|
||||
*/
|
||||
public static boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
/** Have we been created? */
|
||||
protected static boolean created;
|
||||
|
||||
/**
|
||||
* Creates a new instance of ILUT. Cannot be created unless IL has been created.
|
||||
|
|
@ -127,56 +119,25 @@ public class ILUT {
|
|||
if(!IL.isCreated()) {
|
||||
throw new LWJGLException("Cannot create ILUT without having created IL instance");
|
||||
}
|
||||
|
||||
String[] ilutPaths = LWJGLUtil.getLibraryPaths(new String[]{
|
||||
"ILUT", "ILUT.dll",
|
||||
"ILUT", "libILUT.so",
|
||||
"ILUT", "libILUT.dylib"}, ILUT.class.getClassLoader());
|
||||
nCreate(ilutPaths);
|
||||
|
||||
try {
|
||||
ILUT.initNativeStubs();
|
||||
ILUT.ilutInit();
|
||||
created = true;
|
||||
} catch (LWJGLException e) {
|
||||
destroy();
|
||||
throw e;
|
||||
}
|
||||
|
||||
ILNative.createILUT();
|
||||
created = true;
|
||||
}
|
||||
|
||||
static native void initNativeStubs() throws LWJGLException;
|
||||
|
||||
static native void resetNativeStubs(Class clazz);
|
||||
|
||||
/**
|
||||
* Exit cleanly by calling destroy.
|
||||
*/
|
||||
public static void destroy() {
|
||||
resetNativeStubs(ILUT.class);
|
||||
if (created) {
|
||||
nDestroy();
|
||||
ILNative.destroyILUT();
|
||||
created = false;
|
||||
}
|
||||
created = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Native method to create ILUT instance
|
||||
*
|
||||
* @param ilutPaths Array of strings containing paths to search for ILUT library
|
||||
* @return true if ILUT has been created
|
||||
*/
|
||||
protected static native void nCreate(String[] ilutPaths) throws LWJGLException;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
public static boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2004 LWJGL Project
|
||||
* Copyright (c) 2002-2005 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -41,16 +41,16 @@ package org.lwjgl.devil;
|
|||
*/
|
||||
public class ILinfo {
|
||||
public int id; // the image's id
|
||||
public byte data[]; // the image's data
|
||||
public byte data[]; // the image's data
|
||||
public int width; // the image's width
|
||||
public int height; // the image's height
|
||||
public int depth; // the image's depth
|
||||
public byte bpp; // bytes per pixel (not bits) of the image
|
||||
public byte bpp; // bytes per pixel (not bits) of the image
|
||||
public int sizeOfData; // the total size of the data (in bytes)
|
||||
public int format; // image format (in IL enum style)
|
||||
public int type; // image type (in IL enum style)
|
||||
public int origin; // origin of the image
|
||||
public byte palette[]; // the image's palette
|
||||
public byte palette[]; // the image's palette
|
||||
public int palType; // palette type
|
||||
public int palSize; // palette size
|
||||
public int cubeFlags; // flags for what cube map sides are present
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2004 LWJGL Project
|
||||
* Copyright (c) 2002-2005 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2004 LWJGL Project
|
||||
* Copyright (c) 2002-2005 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue