dynamic loading of devil

This commit is contained in:
Brian Matzon 2005-03-25 01:08:18 +00:00
parent c3d6665585
commit ed3dacf6a3
14 changed files with 1924 additions and 828 deletions

File diff suppressed because it is too large Load diff

View file

@ -31,10 +31,16 @@
*/
package org.lwjgl.devil;
import java.io.File;
import java.lang.reflect.Method;
import java.nio.IntBuffer;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import org.lwjgl.BufferChecks;
import org.lwjgl.LWJGLException;
import org.lwjgl.Sys;
/**
* $Id$
@ -42,15 +48,11 @@ import org.lwjgl.LWJGLException;
* The DevIL ILU API.
*
* @author captainjester <captainjester@users.sourceforge.net>
* @author Brian Matzon <brian@matzon.dk>
* @version $Revision$
*/
public class ILU {
/** Have we been created? */
protected static boolean created;
public static final int ILU_VERSION_1_6_7 = 1;
public static final int ILU_VERSION = 167;
public static final int ILU_FILTER = 0x2600;
public static final int ILU_NEAREST = 0x2601;
public static final int ILU_LINEAR = 0x2602;
@ -62,7 +64,7 @@ public class ILU {
public static final int ILU_SCALE_LANCZOS3 = 0x2608;
public static final int ILU_SCALE_MITCHELL = 0x2609;
// Error types
// Error types
public static final int ILU_INVALID_ENUM = 0x0501;
public static final int ILU_OUT_OF_MEMORY = 0x0502;
public static final int ILU_INTERNAL_ERROR = 0x0504;
@ -70,7 +72,7 @@ public class ILU {
public static final int ILU_ILLEGAL_OPERATION = 0x0506;
public static final int ILU_INVALID_PARAM = 0x0509;
// Values
// Values
public static final int ILU_PLACEMENT = 0x0700;
public static final int ILU_LOWER_LEFT = 0x0701;
public static final int ILU_LOWER_RIGHT = 0x0702;
@ -78,23 +80,19 @@ public class ILU {
public static final int ILU_UPPER_RIGHT = 0x0704;
public static final int ILU_CENTER = 0x0705;
public static final int ILU_CONVOLUTION_MATRIX = 0x0710;
// public static final int ILU_VERSION_NUM = IL_VERSION_NUM;
// public static final int ILU_VENDOR = IL_VENDOR;
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;
static {
// System.loadLibrary("ILU");
System.loadLibrary("lwjgl-devil");
}
/**
* @return true if DevIL has been created
* @return true if ILU has been created
*/
public static boolean isCreated() {
return created;
}
public static native void initNativeStubs() throws LWJGLException;
public static native boolean iluAlienify();
public static native boolean iluBlurAvg(int iter);
public static native boolean iluBlurGaussian(int iter);
@ -121,25 +119,18 @@ public class ILU {
BufferChecks.checkDirect(param);
niluGetIntegerv(mode, param, param.position());
}
public static native void niluGetIntegerv(int mode, IntBuffer param, int param_offset);
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);
public static native void iluInit();
private static native void iluInit();
public static native boolean iluInvertAlpha();
public static native int iluLoadImage(String fileName);
public static native boolean iluMirror();
public static native boolean iluNegative();
public static native boolean iluNoisify(float tolerance);
public static native boolean iluPixelize(int pixSize);
// TODO result placed in a pointer
// public static native void iluRegionfv(ILpointf points[], int n);
// TODO result placed in a pointer
// public static native void iluRegioniv(ILpointi points[], int n);
public static native boolean iluReplaceColour(byte red, byte green, byte blue, float tolerance);
public static native boolean iluRotate(float angle);
// TODO Not implemented in the native lib
// public static native boolean iluRotate3D(float x, float y, float z, float Angle);
public static native boolean iluSaturate1f(float saturation);
public static native boolean iluSaturate4f(float r, float g, float b, float saturation);
public static native boolean iluScale(int width, int height, int depth);
@ -147,23 +138,13 @@ public class ILU {
public static native boolean iluSharpen(float factor, int iter);
public static native boolean iluSwapColours();
public static native boolean iluWave(float angle);
/**
*
*/
public static void create() throws LWJGLException {
if (!created) {
nCreate();
ILU.initNativeStubs();
ILU.iluInit();
created = true;
}
}
public static native void nCreate();
// public static native void iluRegionfv(ILpointf points[], int n);
// public static native void iluRegioniv(ILpointi points[], int n);
// public static native boolean iluRotate3D(float x, float y, float z, float Angle);
//DevIL lib allows both spellings of colour.
//Will do the same this way.
/* DevIL lib allows both spellings of colour. We support that too */
// ========================================================================
public static void iluColorsUsed() {
iluColoursUsed();
}
@ -176,4 +157,136 @@ public class ILU {
public static void iluScaleColors(float r, float g, float b) {
iluScaleColours(r, g, b);
}
// ------------------------------------------------------------------------
/**
* Creates a new instance of ILU. Cannot be created unless IL has been created.
*/
public static void create() throws LWJGLException {
if(!IL.isCreated()) {
throw new LWJGLException("Cannot create ILU without having created IL instance");
}
String[] iluPaths = getILUPaths();
nCreate(iluPaths);
created = true;
try {
ILU.initNativeStubs();
ILU.iluInit();
created = true;
} catch (LWJGLException e) {
destroy();
throw e;
}
}
private static native void initNativeStubs() throws LWJGLException;
private static native void resetNativeStubs(Class clazz);
/**
* Exit cleanly by calling destroy.
*/
public static void destroy() {
resetNativeStubs(ILU.class);
if (created) {
nDestroy();
}
created = false;
}
/**
* Native method to create ILU instance
*
* @param iluPaths Array of strings containing paths to search for ILU library
*/
protected static native void nCreate(String[] iluPaths) throws LWJGLException;
/**
* Native method the destroy the ILU
*/
protected static native void nDestroy();
private static String[] getILUPaths() throws LWJGLException {
// need to pass path of possible locations of ILU to native side
List possible_paths = new ArrayList();
String osName = System.getProperty("os.name");
String libname;
String platform_lib_name;
if (osName.startsWith("Win")) {
libname = "ILU";
platform_lib_name = "ILU.dll";
} else if (osName.startsWith("Lin")) {
libname = "ILU";
platform_lib_name = "ILU.so";
} else if (osName.startsWith("Mac")) {
libname = "ILU";
platform_lib_name = "ILU.dylib";
} else {
throw new LWJGLException("Unknown platform: " + osName);
}
// Add all possible paths from java.library.path
String java_library_path = System.getProperty("java.library.path");
StringTokenizer st = new StringTokenizer(System.getProperty("java.library.path"), File.pathSeparator);
while (st.hasMoreTokens()) {
String path = st.nextToken();
possible_paths.add(path + File.separator + platform_lib_name);
}
String classloader_path = getPathFromClassLoader(libname);
if (classloader_path != null) {
Sys.log("getPathFromClassLoader: Path found: " + classloader_path);
possible_paths.add(classloader_path);
}
String lwjgl_classloader_path = getPathFromClassLoader("lwjgl");
if (lwjgl_classloader_path != null) {
Sys.log("getPathFromClassLoader: Path found: " + lwjgl_classloader_path);
possible_paths.add(lwjgl_classloader_path.substring(0, lwjgl_classloader_path.lastIndexOf(File.separator))
+ File.separator + platform_lib_name);
}
//add cwd path
possible_paths.add(platform_lib_name);
//create needed string array
String[] iluPaths = new String[possible_paths.size()];
possible_paths.toArray(iluPaths);
return iluPaths;
}
/**
* Tries to locate ILU from the current ClassLoader
* This method exists because ILU is loaded from native code, and as such
* is exempt from ClassLoader library loading rutines. ILU therefore always fails.
* We therefore invoke the protected method of the ClassLoader to see if it can
* locate it.
*
* @param libname Name of library to search for
* @return Absolute path to library if found, otherwise null
*/
private static String getPathFromClassLoader(String libname) {
try {
Sys.log("getPathFromClassLoader: searching for: " + libname);
Object o = IL.class.getClassLoader();
Class c = o.getClass();
while (c != null) {
try {
Method findLibrary = c.getDeclaredMethod("findLibrary", new Class[] { String.class});
findLibrary.setAccessible(true);
Object[] arguments = new Object[] { libname};
return (String) findLibrary.invoke(o, arguments);
} catch (NoSuchMethodException e) {
c = c.getSuperclass();
}
}
} catch (Exception e) {
Sys.log("Failure locating ILU using classloader:" + e);
}
return null;
}
}

View file

@ -31,7 +31,14 @@
*/
package org.lwjgl.devil;
import java.io.File;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import org.lwjgl.LWJGLException;
import org.lwjgl.Sys;
/**
* $Id$
@ -39,22 +46,17 @@ import org.lwjgl.LWJGLException;
* The DevIL ILUT API.
*
* @author captainjester <captainjester@users.sourceforge.net>
* @author Brian Matzon <brian@matzon.dk>
* @version $Revision$
*/
public class ILUT {
/** Have we been created? */
protected static boolean created;
public static final int ILUT_VERSION_1_6_7 = 1;
public static final int ILUT_VERSION = 167;
// Attribute Bits
// Attribute Bits
public static final int ILUT_OPENGL_BIT = 0x00000001;
public static final int ILUT_ALL_ATTRIB_BITS = 0x000FFFFF;
// Error Types
// Error Types
public static final int ILUT_INVALID_ENUM = 0x0501;
public static final int ILUT_OUT_OF_MEMORY = 0x0502;
public static final int ILUT_INVALID_VALUE = 0x0505;
@ -67,7 +69,7 @@ public class ILUT {
public static final int ILUT_NOT_SUPPORTED = 0x0550;
// State Definitions
// State Definitions
public static final int ILUT_PALETTE_MODE = 0x0600;
public static final int ILUT_OPENGL_CONV = 0x0610;
public static final int ILUT_MAXTEX_WIDTH = 0x0630;
@ -75,46 +77,32 @@ public class ILUT {
public static final int ILUT_MAXTEX_DEPTH = 0x0632;
public static final int ILUT_GL_USE_S3TC = 0x0634;
public static final int ILUT_GL_GEN_S3TC = 0x0635;
// This new state does automatic texture target detection
// if enabled. Currently, only cubemap detection is supported.
// if the current image is no cubemap, the 2d texture is chosen.
public static final int ILUT_GL_AUTODETECT_TEXTURE_TARGET = 0x0807;
// The different rendering api's...more to be added later?
// The different rendering api's...more to be added later?
public static final int ILUT_OPENGL = 0;
static {
// System.loadLibrary("ILU");
System.loadLibrary("lwjgl-devil");
}
public static final int ILUT_VENDOR = IL.IL_VENDOR;
/** Have we been created? */
protected static boolean created;
/**
* @return true if DevIL has been created
*/
public static boolean isCreated() {
return created;
}
public static native void initNativeStubs() throws LWJGLException;
public static native boolean ilutRenderer(int renderer);
// ImageLib Utility Toolkit Functions
public static native boolean ilutRenderer(int renderer);
public static native boolean ilutDisable(int mode);
public static native boolean ilutEnable(int mode);
public static native boolean ilutGetBoolean(int mode);
// public static native void ilutGetBooleanv(int mode, ILboolean *Param);
public static native int ilutGetInteger(int mode);
// public static native void ilutGetIntegerv(int mode, ILint *Param);
public static native String ilutGetString(int stringName);
public static native void ilutInit();
private static native void ilutInit();
public static native boolean ilutIsDisabled(int mode);
public static native boolean ilutIsEnabled(int mode);
public static native void ilutPopAttrib();
public static native void ilutPushAttrib(int bits);
public static native void ilutSetInteger(int Mode, int param);
// public static native void ilutGetBooleanv(int mode, ILboolean *Param);
// public static native void ilutGetIntegerv(int mode, ILint *Param);
// ImageLib Utility Toolkit's OpenGL Functions
// ImageLib Utility Toolkit's OpenGL Functions
public static native int ilutGLBindTexImage();
public static native int ilutGLBindMipmaps();
public static native boolean ilutGLBuildMipmaps();
@ -124,17 +112,142 @@ 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;
}
/**
* Creates a new instance of ILUT. Cannot be created unless IL has been created.
*/
public static void create() throws LWJGLException {
if (!created) {
nCreate();
ILUT.initNativeStubs();
ILUT.ilutInit();
ilutRenderer(ILUT_OPENGL);
created = true;
}
if(!IL.isCreated()) {
throw new LWJGLException("Cannot create ILUT without having created IL instance");
}
String[] ilutPaths = getILUTPaths();
nCreate(ilutPaths);
created = true;
try {
ILUT.initNativeStubs();
ILUT.ilutInit();
created = true;
} catch (LWJGLException e) {
destroy();
throw e;
}
}
public static native void nCreate();
private static native void initNativeStubs() throws LWJGLException;
private static native void resetNativeStubs(Class clazz);
/**
* Exit cleanly by calling destroy.
*/
public static void destroy() {
resetNativeStubs(ILUT.class);
if (created) {
nDestroy();
}
created = false;
}
/**
* Native method to create ILUT instance
*
* @param iluPaths Array of strings containing paths to search for ILUT library
*/
protected static native void nCreate(String[] ilutPaths) throws LWJGLException;
/**
* Native method the destroy the ILUT
*/
protected static native void nDestroy();
private static String[] getILUTPaths() throws LWJGLException {
// need to pass path of possible locations of IL to native side
List possible_paths = new ArrayList();
String osName = System.getProperty("os.name");
String libname;
String platform_lib_name;
if (osName.startsWith("Win")) {
libname = "ILUT";
platform_lib_name = "ILUT.dll";
} else if (osName.startsWith("Lin")) {
libname = "ILUT";
platform_lib_name = "ILUT.so";
} else if (osName.startsWith("Mac")) {
libname = "ILUT";
platform_lib_name = "ILUT.dylib";
} else {
throw new LWJGLException("Unknown platform: " + osName);
}
// Add all possible paths from java.library.path
String java_library_path = System.getProperty("java.library.path");
StringTokenizer st = new StringTokenizer(System.getProperty("java.library.path"), File.pathSeparator);
while (st.hasMoreTokens()) {
String path = st.nextToken();
possible_paths.add(path + File.separator + platform_lib_name);
}
String classloader_path = getPathFromClassLoader(libname);
if (classloader_path != null) {
Sys.log("getPathFromClassLoader: Path found: " + classloader_path);
possible_paths.add(classloader_path);
}
String lwjgl_classloader_path = getPathFromClassLoader("lwjgl");
if (lwjgl_classloader_path != null) {
Sys.log("getPathFromClassLoader: Path found: " + lwjgl_classloader_path);
possible_paths.add(lwjgl_classloader_path.substring(0, lwjgl_classloader_path.lastIndexOf(File.separator))
+ File.separator + platform_lib_name);
}
//add cwd path
possible_paths.add(platform_lib_name);
//create needed string array
String[] ilutPaths = new String[possible_paths.size()];
possible_paths.toArray(ilutPaths);
return ilutPaths;
}
/**
* Tries to locate ILUT from the current ClassLoader
* This method exists because ILUT is loaded from native code, and as such
* is exempt from ClassLoader library loading rutines. ILUT therefore always fails.
* We therefore invoke the protected method of the ClassLoader to see if it can
* locate it.
*
* @param libname Name of library to search for
* @return Absolute path to library if found, otherwise null
*/
private static String getPathFromClassLoader(String libname) {
try {
Sys.log("getPathFromClassLoader: searching for: " + libname);
Object o = IL.class.getClassLoader();
Class c = o.getClass();
while (c != null) {
try {
Method findLibrary = c.getDeclaredMethod("findLibrary", new Class[] { String.class});
findLibrary.setAccessible(true);
Object[] arguments = new Object[] { libname};
return (String) findLibrary.invoke(o, arguments);
} catch (NoSuchMethodException e) {
c = c.getSuperclass();
}
}
} catch (Exception e) {
Sys.log("Failure locating ILUT using classloader:" + e);
}
return null;
}
}

View file

@ -37,6 +37,7 @@ import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;
/**
* $Id$
* <p>The core DevIL and ILU API.</p>
@ -45,67 +46,73 @@ import java.nio.IntBuffer;
* @version $Revision$
*/
public class BasicTest {
public static void main(String args[]) {
try {
IL.create();
ILU.create();
}
catch(Exception e) {
e.printStackTrace();
System.exit(0);
}
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
System.out.println("ilGenImages");
IntBuffer im = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
IL.ilGenImages(1, im);
System.out.println("ilBindImage");
IL.ilBindImage(im.get(0));
IL.ilEnable(IL.IL_ORIGIN_SET);
IL.ilOriginFunc(IL.IL_ORIGIN_UPPER_LEFT);
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
String imageFile = "F:/Apps/Java/eclipse/workspace/LWJGL/res/ILtest.tga";
URL imageURL = BasicTest.class.getResource("/res/ILtest.tga");
System.out.println("ilLoadFromURL " + imageURL);
System.out.println("load lump = " + IL.ilLoadFromURL(imageURL));
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
int newIm = IL.ilCloneCurImage();
IL.ilCopyImage(im.get(0));
IL.ilBindImage(newIm);
ByteBuffer buf = IL.ilGetData();
System.out.println("ilGetData");
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
int limit = buf.limit();
System.out.println("limit = " + limit);
for(int i=0;i<buf.limit();i+=3) {
System.out.println(buf.get(i) + " " + buf.get(i + 1) + " " + buf.get(i + 2));
}
System.out.println("current image = " + im.get(0) + " IL.ilGetInteger(IL.IL_ACTIVE_IMAGE) = " + IL.ilGetInteger(IL.IL_ACTIVE_IMAGE));
System.out.println("Version: " + IL.ilGetInteger(IL.IL_VERSION_NUM));
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
ILinfo info = new ILinfo();
ILU.iluGetImageInfo(info);
System.out.println("info.id = " + info.id);
System.out.println("info.width = " + info.width);
System.out.println("info.height = " + info.height);
System.out.println("info.depth = " + info.depth);
System.out.println("info.bpp = " + info.bpp);
System.out.println("info.sizeOfData = " + info.sizeOfData);
System.out.println("info.format = " + info.format);
System.out.println("info.type = " + info.type);
System.out.println("info.origin = " + info.origin);
System.out.println("info.palType = " + info.palType);
System.out.println("info.palSize = " + info.palSize);
System.out.println("info.numNext = " + info.numNext);
System.out.println("info.numMips = " + info.numMips);
System.out.println("info.numLayers = " + info.numLayers);
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
// ILpointf pointf[] = new ILpointf[3];
// ILU.iluRegionfv(pointf, pointf.length);
// for(int i=0;i<pointf.length;i++) {
// System.out.println("point[" + i + "] x = " + pointf[i].x + " y = " + pointf[i].y);
// }
}
public static void main(String args[]) {
try {
IL.create();
ILU.create();
ILUT.create();
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
System.out.println("ilGenImages");
IntBuffer im = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
IL.ilGenImages(1, im);
System.out.println("ilBindImage");
IL.ilBindImage(im.get(0));
IL.ilEnable(IL.IL_ORIGIN_SET);
IL.ilOriginFunc(IL.IL_ORIGIN_UPPER_LEFT);
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
URL imageURL = BasicTest.class.getResource("/res/ILtest.tga");
System.out.println("ilLoadFromURL " + imageURL);
System.out.println("load lump = " + IL.ilLoadFromURL(imageURL));
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
int newIm = IL.ilCloneCurImage();
IL.ilCopyImage(im.get(0));
IL.ilBindImage(newIm);
ByteBuffer buf = IL.ilGetData();
System.out.println("ilGetData");
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
int limit = buf.limit();
System.out.println("limit = " + limit);
for (int i = 0; i < buf.limit(); i += 3) {
System.out.println(buf.get(i) + " " + buf.get(i + 1) + " " + buf.get(i + 2));
}
System.out.println("current image = " + im.get(0) + " IL.ilGetInteger(IL.IL_ACTIVE_IMAGE) = "
+ IL.ilGetInteger(IL.IL_ACTIVE_IMAGE));
System.out.println("Version: " + IL.ilGetInteger(IL.IL_VERSION_NUM));
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
ILinfo info = new ILinfo();
ILU.iluGetImageInfo(info);
System.out.println("info.id = " + info.id);
System.out.println("info.width = " + info.width);
System.out.println("info.height = " + info.height);
System.out.println("info.depth = " + info.depth);
System.out.println("info.bpp = " + info.bpp);
System.out.println("info.sizeOfData = " + info.sizeOfData);
System.out.println("info.format = " + info.format);
System.out.println("info.type = " + info.type);
System.out.println("info.origin = " + info.origin);
System.out.println("info.palType = " + info.palType);
System.out.println("info.palSize = " + info.palSize);
System.out.println("info.numNext = " + info.numNext);
System.out.println("info.numMips = " + info.numMips);
System.out.println("info.numLayers = " + info.numLayers);
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
System.out.println("ILUT Vendor: " + ILUT.ilutGetString(ILUT.ILUT_VENDOR));
try {
ILUT.destroy();
ILU.destroy();
IL.destroy();
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
}
}

View file

@ -0,0 +1,124 @@
#ifndef __DEVIL_COMMON_H__
#define __DEVIL_COMMON_H__
#include <jni.h>
#include <stdio.h>
#include <string.h>
#include "org_lwjgl_devil_IL.h"
#include "org_lwjgl_devil_ILU.h"
#include "org_lwjgl_devil_ILUT.h"
#include "common_tools.h"
/*-----------------------------------------*/
typedef unsigned int GLuint;
#ifdef _UNICODE
#ifndef _WIN32_WCE
#include <wchar.h>
#endif
typedef wchar_t* ILstring;
#else
typedef char* ILstring;
#endif//_UNICODE
#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) || defined(__LCC__)
#define ILAPIENTRY __stdcall
#define IL_PACKSTRUCT
//#elif defined(linux) || defined(MACOSX) || defined(__CYGWIN__) //fix bug 840364
#elif defined( __GNUC__ )
// this should work for any of the above commented platforms
// plus any platform using GCC
#define ILAPIENTRY
#define IL_PACKSTRUCT __attribute__ ((packed))
#else
#define ILAPIENTRY
#define IL_PACKSTRUCT
#endif
// This is from Win32's <wingdi.h> and <winnt.h>
#if defined(__LCC__)
#define ILAPI __stdcall
#elif defined(_WIN32) //changed 20031221 to fix bug 840421
#ifdef IL_STATIC_LIB
#define ILAPI
#else
#ifdef _IL_BUILD_LIBRARY
#define ILAPI __declspec(dllexport)
#else
#define ILAPI __declspec(dllimport)
#endif
#endif
#elif __APPLE__
#define ILAPI extern
#else
#define ILAPI
#endif
typedef void* ILHANDLE;
typedef unsigned int ILenum;
typedef unsigned char ILboolean;
typedef unsigned int ILbitfield;
typedef char ILbyte;
typedef short ILshort;
typedef int ILint;
typedef int ILsizei;
typedef unsigned char ILubyte;
typedef unsigned short ILushort;
typedef unsigned int ILuint;
typedef float ILfloat;
typedef float ILclampf;
typedef double ILdouble;
typedef double ILclampd;
typedef void ILvoid;
typedef struct ILinfo
{
ILuint Id; // the image's id
ILubyte *Data; // the image's data
ILuint Width; // the image's width
ILuint Height; // the image's height
ILuint Depth; // the image's depth
ILubyte Bpp; // bytes per pixel (not bits) of the image
ILuint SizeOfData; // the total size of the data (in bytes)
ILenum Format; // image format (in IL enum style)
ILenum Type; // image type (in IL enum style)
ILenum Origin; // origin of the image
ILubyte *Palette; // the image's palette
ILenum PalType; // palette type
ILuint PalSize; // palette size
ILenum CubeFlags; // flags for what cube map sides are present
ILuint NumNext; // number of images following
ILuint NumMips; // number of mipmaps
ILuint NumLayers; // number of layers
} ILinfo;
typedef struct ILpointf
{
ILfloat x, y;
} ILpointf;
typedef struct ILpointi
{
ILint x, y;
} ILpointi;
#define IL_IMAGE_WIDTH 0x0DE4
#define IL_IMAGE_HEIGHT 0x0DE5
#define IL_IMAGE_BYTES_PER_PIXEL 0x0DE8
// Registered format procedures
typedef ILenum (ILAPIENTRY *IL_LOADPROC)(const ILstring);
typedef ILenum (ILAPIENTRY *IL_SAVEPROC)(const ILstring);
/*-----------------------------------------*/
#if defined(_WIN32) && !defined(APIENTRY)
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#endif
#ifndef APIENTRY
#define APIENTRY
#endif
#endif /* __EXTIL_H__ */

View file

@ -1,67 +1,115 @@
#include "extil.h"
/* turn off the warning for the borland compiler*/
#ifdef __BORLANDC__
#pragma warn -8064
#pragma warn -8065
#endif /* __BORLANDC__ */
/* Handle to devil Library */
#ifdef _WIN32
HMODULE devILhandle = NULL;
static HMODULE devILhandle;
#endif
#ifdef _X11
static void* devILhandle;
#endif
#ifdef _MACOSX
#include <mach-o/dyld.h>
#include <stdlib.h>
#include <string.h>
static const struct mach_header* devILhandle;
#endif
/* getProcAddress */
void *extil_GetProcAddress(const char *name) {
/**
* Retrieves a function pointer from the devil library
* @param function Name of function to retrieve
*/
static void *NativeGetFunctionPointer(const char *function) {
#ifdef _WIN32
void *t = GetProcAddress(devILhandle, name);
if (t == NULL) {
printfDebug("Could not locate symbol %s\n", name);
}
return t;
return GetProcAddress(devILhandle, function);
#endif
#ifdef _X11
return dlsym(devILhandle, function);
#endif
#ifdef _MACOSX
char *mac_symbol_name = (char *)malloc((strlen(function) + 2)*sizeof(char));
if (mac_symbol_name == NULL)
return NULL;
mac_symbol_name[0] = '_';
strcpy(&(mac_symbol_name[1]), function);
NSSymbol symbol = NSLookupSymbolInImage(devILhandle, mac_symbol_name, NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
free(mac_symbol_name);
if (symbol == NULL)
return NULL;
return NSAddressOfSymbol(symbol);
#endif
}
/**
* Retrieves a pointer to the named function
*
* @param function Name of function
* @return pointer to named function, or NULL if not found
*/
static void* extil_GetProcAddress(const char* function) {
void *p = NativeGetFunctionPointer(function);
if (p == NULL) {
printfDebug("Could not locate symbol %s\n", function);
}
return p;
}
/**
* Initializes all functions for class
*/
void extil_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions) {
ext_InitializeClass(env, clazz, &extil_GetProcAddress, num_functions, functions);
}
/**
* Opens the native library
*/
bool extil_Open(JNIEnv *env, jobjectArray ilPaths) {
jsize pathcount = (*env)->GetArrayLength(env, ilPaths);
int i;
jstring path;
char *path_str;
bool extil_InitializeFunctions(int num_functions, ExtFunction *functions) {
return ext_InitializeFunctions(&extil_GetProcAddress, num_functions, functions);
}
printfDebug("Found %d devil paths\n", (int)pathcount);
for(i=0;i<pathcount;i++) {
path = (jstring) (*env)->GetObjectArrayElement(env, ilPaths, i);
path_str = GetStringNativeChars(env, path);
printfDebug("Testing '%s'\n", path_str);
#ifdef _WIN32
bool extil_Open(JNIEnv *env) {
bool result = true;
devILhandle = LoadLibrary(path_str);
#endif
#ifdef _X11
devILhandle = dlopen(path_str, RTLD_LAZY);
#endif
#ifdef _MACOSX
devILhandle = NSAddImage(path_str, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
#endif
if (devILhandle != NULL) {
printfDebug("Found devil at '%s'\n", path_str);
}
if (devILhandle == NULL) {
// load the dynamic libraries for DevIL
devILhandle = LoadLibrary("DevIL.dll");
if (devILhandle == NULL) {
printf("\r\nfailed to load DevIL");
result = false;
}
}
return result;
free(path_str);
if (devILhandle != NULL) {
return true;
}
}
throwException(env, "Could not load devil library.");
return false;
}
#endif /* WIN32 */
/**
* Closes the native library
*/
void extil_Close(void) {
#ifdef _WIN32
FreeLibrary(devILhandle);
devILhandle = NULL;
FreeLibrary(devILhandle);
#endif
}
/* turn on the warning for the borland compiler*/
#ifdef __BORLANDC__
#pragma warn .8064
#pragma warn .8065
#endif /* __BORLANDC__ */
#ifdef _X11
if (devILhandle != NULL) {
dlclose(devILhandle);
}
#endif
#ifdef _MACOSX
// Cannot remove the image
#endif
devILhandle = NULL;
}

View file

@ -1,53 +1,10 @@
#ifndef __EXTIL_H__
#define __EXTIL_H__
#include <jni.h>
#include <stdio.h>
#include <string.h>
//#include <gl/gl.h>
#include <IL/il.h>
#include <IL/ilu.h>
#include <IL/ilut.h>
#include "org_lwjgl_devil_IL.h"
#include "org_lwjgl_devil_ILU.h"
#include "org_lwjgl_devil_ILUT.h"
#include "common_tools.h"
#include "devil-common.h"
/*-----------------------------------------*/
/*-----------------------------------------*/
#if defined(_WIN32) && !defined(APIENTRY)
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#endif
#define __ilext_h_
#define __ILEXT_H_
#define __il_h_
#define __IL_H__
#include <string.h>
#ifndef APIENTRY
#define APIENTRY
#endif
#include "common_tools.h"
#ifdef __cplusplus
extern "C" {
#endif
/* initializes everything, call this right after the rc is created. the function returns 0 if successful */
extern bool extil_Open(JNIEnv *env);
extern bool extil_Open(JNIEnv *env, jobjectArray ilPaths);
extern void extil_Close(void);
extern void extil_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions);
extern bool extil_InitializeFunctions(int num_functions, ExtFunction *functions);
#ifdef __cplusplus
}
#endif
#endif /* __EXTIL_H__ */
#endif

View file

@ -0,0 +1,115 @@
#include "extilu.h"
/* Handle to ilu Library */
#ifdef _WIN32
static HMODULE devILUhandle;
#endif
#ifdef _X11
static void* devILUhandle;
#endif
#ifdef _MACOSX
#include <mach-o/dyld.h>
#include <stdlib.h>
#include <string.h>
static const struct mach_header* devILUhandle;
#endif
/**
* Retrieves a function pointer from the ilu library
* @param function Name of function to retrieve
*/
static void *NativeGetFunctionPointer(const char *function) {
#ifdef _WIN32
return GetProcAddress(devILUhandle, function);
#endif
#ifdef _X11
return dlsym(devILUhandle, function);
#endif
#ifdef _MACOSX
char *mac_symbol_name = (char *)malloc((strlen(function) + 2)*sizeof(char));
if (mac_symbol_name == NULL)
return NULL;
mac_symbol_name[0] = '_';
strcpy(&(mac_symbol_name[1]), function);
NSSymbol symbol = NSLookupSymbolInImage(devILUhandle, mac_symbol_name, NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
free(mac_symbol_name);
if (symbol == NULL)
return NULL;
return NSAddressOfSymbol(symbol);
#endif
}
/**
* Retrieves a pointer to the named function
*
* @param function Name of function
* @return pointer to named function, or NULL if not found
*/
static void* extilu_GetProcAddress(const char* function) {
void *p = NativeGetFunctionPointer(function);
if (p == NULL) {
printfDebug("Could not locate symbol %s\n", function);
}
return p;
}
/**
* Initializes all functions for class
*/
void extilu_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions) {
ext_InitializeClass(env, clazz, &extilu_GetProcAddress, num_functions, functions);
}
/**
* Opens the native library
*/
bool extilu_Open(JNIEnv *env, jobjectArray ilPaths) {
jsize pathcount = (*env)->GetArrayLength(env, ilPaths);
int i;
jstring path;
char *path_str;
printfDebug("Found %d ilu paths\n", (int)pathcount);
for(i=0;i<pathcount;i++) {
path = (jstring) (*env)->GetObjectArrayElement(env, ilPaths, i);
path_str = GetStringNativeChars(env, path);
printfDebug("Testing '%s'\n", path_str);
#ifdef _WIN32
devILUhandle = LoadLibrary(path_str);
#endif
#ifdef _X11
devILUhandle = dlopen(path_str, RTLD_LAZY);
#endif
#ifdef _MACOSX
devILUhandle = NSAddImage(path_str, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
#endif
if (devILUhandle != NULL) {
printfDebug("Found ilu at '%s'\n", path_str);
}
free(path_str);
if (devILUhandle != NULL) {
return true;
}
}
throwException(env, "Could not load ilu library.");
return false;
}
/**
* Closes the native library
*/
void extilu_Close(void) {
#ifdef _WIN32
FreeLibrary(devILUhandle);
#endif
#ifdef _X11
if (devILUhandle != NULL) {
dlclose(devILUhandle);
}
#endif
#ifdef _MACOSX
// Cannot remove the image
#endif
devILUhandle = NULL;
}

View file

@ -0,0 +1,10 @@
#ifndef __EXTILU_H__
#define __EXTILU_H__
#include "devil-common.h"
extern bool extilu_Open(JNIEnv *env, jobjectArray ilPaths);
extern void extilu_Close(void);
extern void extilu_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions);
#endif

View file

@ -0,0 +1,115 @@
#include "extilut.h"
/* Handle to ilut Library */
#ifdef _WIN32
static HMODULE devILUThandle;
#endif
#ifdef _X11
static void* devILUThandle;
#endif
#ifdef _MACOSX
#include <mach-o/dyld.h>
#include <stdlib.h>
#include <string.h>
static const struct mach_header* devILUThandle;
#endif
/**
* Retrieves a function pointer from the ilut library
* @param function Name of function to retrieve
*/
static void *NativeGetFunctionPointer(const char *function) {
#ifdef _WIN32
return GetProcAddress(devILUThandle, function);
#endif
#ifdef _X11
return dlsym(devILUThandle, function);
#endif
#ifdef _MACOSX
char *mac_symbol_name = (char *)malloc((strlen(function) + 2)*sizeof(char));
if (mac_symbol_name == NULL)
return NULL;
mac_symbol_name[0] = '_';
strcpy(&(mac_symbol_name[1]), function);
NSSymbol symbol = NSLookupSymbolInImage(devILUThandle, mac_symbol_name, NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
free(mac_symbol_name);
if (symbol == NULL)
return NULL;
return NSAddressOfSymbol(symbol);
#endif
}
/**
* Retrieves a pointer to the named function
*
* @param function Name of function
* @return pointer to named function, or NULL if not found
*/
static void* extilut_GetProcAddress(const char* function) {
void *p = NativeGetFunctionPointer(function);
if (p == NULL) {
printfDebug("Could not locate symbol %s\n", function);
}
return p;
}
/**
* Initializes all functions for class
*/
void extilut_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions) {
ext_InitializeClass(env, clazz, &extilut_GetProcAddress, num_functions, functions);
}
/**
* Opens the native library
*/
bool extilut_Open(JNIEnv *env, jobjectArray ilPaths) {
jsize pathcount = (*env)->GetArrayLength(env, ilPaths);
int i;
jstring path;
char *path_str;
printfDebug("Found %d ilut paths\n", (int)pathcount);
for(i=0;i<pathcount;i++) {
path = (jstring) (*env)->GetObjectArrayElement(env, ilPaths, i);
path_str = GetStringNativeChars(env, path);
printfDebug("Testing '%s'\n", path_str);
#ifdef _WIN32
devILUThandle = LoadLibrary(path_str);
#endif
#ifdef _X11
devILUThandle = dlopen(path_str, RTLD_LAZY);
#endif
#ifdef _MACOSX
devILUThandle = NSAddImage(path_str, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
#endif
if (devILUThandle != NULL) {
printfDebug("Found ilut at '%s'\n", path_str);
}
free(path_str);
if (devILUThandle != NULL) {
return true;
}
}
throwException(env, "Could not load ilut library.");
return false;
}
/**
* Closes the native library
*/
void extilut_Close(void) {
#ifdef _WIN32
FreeLibrary(devILUThandle);
#endif
#ifdef _X11
if (devILUThandle != NULL) {
dlclose(devILUThandle);
}
#endif
#ifdef _MACOSX
// Cannot remove the image
#endif
devILUThandle = NULL;
}

View file

@ -0,0 +1,10 @@
#ifndef __EXTILUT_H__
#define __EXTILUT_H__
#include "devil-common.h"
extern bool extilut_Open(JNIEnv *env, jobjectArray ilPaths);
extern void extilut_Close(void);
extern void extilut_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions);
#endif

View file

@ -1,5 +1,179 @@
#include "extil.h"
typedef ILboolean (ILAPIENTRY *ilActiveImagePROC) (ILuint Number);
typedef ILboolean (ILAPIENTRY *ilActiveLayerPROC) (ILuint Number);
typedef ILboolean (ILAPIENTRY *ilActiveMipmapPROC) (ILuint Number);
typedef ILboolean (ILAPIENTRY *ilApplyPalPROC) (const ILstring FileName);
typedef ILboolean (ILAPIENTRY *ilApplyProfilePROC) (const ILstring InProfile, const ILstring OutProfile);
typedef ILvoid (ILAPIENTRY *ilBindImagePROC) (ILuint Image);
typedef ILboolean (ILAPIENTRY *ilBlitPROC) (ILuint Source, ILint DestX, ILint DestY, ILint DestZ, ILuint SrcX, ILuint SrcY, ILuint SrcZ, ILuint Width, ILuint Height, ILuint Depth);
typedef ILvoid (ILAPIENTRY *ilClearColourPROC) (ILclampf Red, ILclampf Green, ILclampf Blue, ILclampf Alpha);
typedef ILboolean (ILAPIENTRY *ilClearImagePROC) (ILvoid);
typedef ILuint (ILAPIENTRY *ilCloneCurImagePROC) (ILvoid);
typedef ILboolean (ILAPIENTRY *ilCompressFuncPROC) (ILenum Mode);
typedef ILboolean (ILAPIENTRY *ilConvertImagePROC) (ILenum DestFormat, ILenum DestType);
typedef ILboolean (ILAPIENTRY *ilConvertPalPROC) (ILenum DestFormat);
typedef ILboolean (ILAPIENTRY *ilCopyImagePROC) (ILuint Src);
typedef ILuint (ILAPIENTRY *ilCopyPixelsPROC) (ILuint XOff, ILuint YOff, ILuint ZOff, ILuint Width, ILuint Height, ILuint Depth, ILenum Format, ILenum Type, ILvoid *Data);
typedef ILuint (ILAPIENTRY *ilCreateSubImagePROC) (ILenum Type, ILuint Num);
typedef ILboolean (ILAPIENTRY *ilDefaultImagePROC) (ILvoid);
typedef ILvoid (ILAPIENTRY *ilDeleteImagesPROC) (ILsizei Num, const ILuint *Images);
typedef ILboolean (ILAPIENTRY *ilDisablePROC) (ILenum Mode);
typedef ILboolean (ILAPIENTRY *ilEnablePROC) (ILenum Mode);
typedef ILboolean (ILAPIENTRY *ilFormatFuncPROC) (ILenum Mode);
typedef ILvoid (ILAPIENTRY *ilGenImagesPROC) (ILsizei Num, ILuint *Images);
typedef ILubyte* (ILAPIENTRY *ilGetAlphaPROC) (ILenum Type);
typedef ILvoid (ILAPIENTRY *ilModAlphaPROC) ( ILint AlphaValue );
typedef ILvoid (ILAPIENTRY *ilSetAlphaPROC) ( ILuint AlphaValue );
typedef ILboolean (ILAPIENTRY *ilGetBooleanPROC) (ILenum Mode);
typedef ILvoid (ILAPIENTRY *ilGetBooleanvPROC) (ILenum Mode, ILboolean *Param);
typedef ILubyte* (ILAPIENTRY *ilGetDataPROC) (ILvoid);
typedef ILuint (ILAPIENTRY *ilGetDXTCDataPROC) (ILvoid *Buffer, ILuint BufferSize, ILenum DXTCFormat);
typedef ILenum (ILAPIENTRY *ilGetErrorPROC) (ILvoid);
typedef ILint (ILAPIENTRY *ilGetIntegerPROC) (ILenum Mode);
typedef ILvoid (ILAPIENTRY *ilGetIntegervPROC) (ILenum Mode, ILint *Param);
typedef ILuint (ILAPIENTRY *ilGetLumpPosPROC) (ILvoid);
typedef ILubyte* (ILAPIENTRY *ilGetPalettePROC) (ILvoid);
typedef const ILstring (ILAPIENTRY *ilGetStringPROC) (ILenum StringName);
typedef ILvoid (ILAPIENTRY *ilHintPROC) (ILenum Target, ILenum Mode);
typedef ILvoid (ILAPIENTRY *ilInitPROC) (ILvoid);
typedef ILboolean (ILAPIENTRY *ilIsDisabledPROC) (ILenum Mode);
typedef ILboolean (ILAPIENTRY *ilIsEnabledPROC) (ILenum Mode);
typedef ILboolean (ILAPIENTRY *ilIsImagePROC) (ILuint Image);
typedef ILboolean (ILAPIENTRY *ilIsValidPROC) (ILenum Type, const ILstring FileName);
typedef ILboolean (ILAPIENTRY *ilIsValidFPROC) (ILenum Type, ILHANDLE File);
typedef ILboolean (ILAPIENTRY *ilIsValidLPROC) (ILenum Type, ILvoid *Lump, ILuint Size);
typedef ILvoid (ILAPIENTRY *ilKeyColourPROC) (ILclampf Red, ILclampf Green, ILclampf Blue, ILclampf Alpha);
typedef ILboolean (ILAPIENTRY *ilLoadPROC) (ILenum Type, const ILstring FileName);
typedef ILboolean (ILAPIENTRY *ilLoadFPROC) (ILenum Type, ILHANDLE File);
typedef ILboolean (ILAPIENTRY *ilLoadImagePROC) (const ILstring FileName);
typedef ILboolean (ILAPIENTRY *ilLoadLPROC) (ILenum Type, ILvoid *Lump, ILuint Size);
typedef ILboolean (ILAPIENTRY *ilLoadPalPROC) (const ILstring FileName);
typedef ILboolean (ILAPIENTRY *ilOriginFuncPROC) (ILenum Mode);
typedef ILboolean (ILAPIENTRY *ilOverlayImagePROC) (ILuint Source, ILint XCoord, ILint YCoord, ILint ZCoord);
typedef ILvoid (ILAPIENTRY *ilPopAttribPROC) (ILvoid);
typedef ILvoid (ILAPIENTRY *ilPushAttribPROC) (ILuint Bits);
typedef ILvoid (ILAPIENTRY *ilRegisterFormatPROC) (ILenum Format);
typedef ILboolean (ILAPIENTRY *ilRegisterLoadPROC) (const ILstring Ext, IL_LOADPROC Load);
typedef ILboolean (ILAPIENTRY *ilRegisterMipNumPROC) (ILuint Num);
typedef ILboolean (ILAPIENTRY *ilRegisterNumImagesPROC) (ILuint Num);
typedef ILvoid (ILAPIENTRY *ilRegisterOriginPROC) (ILenum Origin);
typedef ILvoid (ILAPIENTRY *ilRegisterPalPROC) (ILvoid *Pal, ILuint Size, ILenum Type);
typedef ILboolean (ILAPIENTRY *ilRegisterSavePROC) (const ILstring Ext, IL_SAVEPROC Save);
typedef ILvoid (ILAPIENTRY *ilRegisterTypePROC) (ILenum Type);
typedef ILboolean (ILAPIENTRY *ilRemoveLoadPROC) (const ILstring Ext);
typedef ILboolean (ILAPIENTRY *ilRemoveSavePROC) (const ILstring Ext);
typedef ILvoid (ILAPIENTRY *ilResetMemoryPROC) (ILvoid);
typedef ILvoid (ILAPIENTRY *ilResetReadPROC) (ILvoid);
typedef ILvoid (ILAPIENTRY *ilResetWritePROC) (ILvoid);
typedef ILboolean (ILAPIENTRY *ilSavePROC) (ILenum Type, const ILstring FileName);
typedef ILuint (ILAPIENTRY *ilSaveFPROC) (ILenum Type, ILHANDLE File);
typedef ILboolean (ILAPIENTRY *ilSaveImagePROC) (const ILstring FileName);
typedef ILuint (ILAPIENTRY *ilSaveLPROC) (ILenum Type, ILvoid *Lump, ILuint Size);
typedef ILboolean (ILAPIENTRY *ilSavePalPROC) (const ILstring FileName);
typedef ILboolean (ILAPIENTRY *ilSetDataPROC) (ILvoid *Data);
typedef ILboolean (ILAPIENTRY *ilSetDurationPROC) (ILuint Duration);
typedef ILvoid (ILAPIENTRY *ilSetIntegerPROC) (ILenum Mode, ILint Param);
typedef ILvoid (ILAPIENTRY *ilSetMemoryPROC) (mAlloc, mFree);
typedef ILvoid (ILAPIENTRY *ilSetPixelsPROC) (ILint XOff, ILint YOff, ILint ZOff, ILuint Width, ILuint Height, ILuint Depth, ILenum Format, ILenum Type, ILvoid *Data);
typedef ILvoid (ILAPIENTRY *ilSetReadPROC) (fOpenRProc, fCloseRProc, fEofProc, fGetcProc, fReadProc, fSeekRProc, fTellRProc);
typedef ILvoid (ILAPIENTRY *ilSetStringPROC) (ILenum Mode, const char *String);
typedef ILvoid (ILAPIENTRY *ilSetWritePROC) (fOpenWProc, fCloseWProc, fPutcProc, fSeekWProc, fTellWProc, fWriteProc);
typedef ILvoid (ILAPIENTRY *ilShutDownPROC) (ILvoid);
typedef ILboolean (ILAPIENTRY *ilTexImagePROC) (ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILenum Format, ILenum Type, ILvoid *Data);
typedef ILboolean (ILAPIENTRY *ilTypeFuncPROC) (ILenum Mode);
typedef ILboolean (ILAPIENTRY *ilLoadDataPROC) (const ILstring FileName, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp);
typedef ILboolean (ILAPIENTRY *ilLoadDataFPROC) (ILHANDLE File, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp);
typedef ILboolean (ILAPIENTRY *ilLoadDataLPROC) (ILvoid *Lump, ILuint Size, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp);
typedef ILboolean (ILAPIENTRY *ilSaveDataPROC) (const ILstring FileName);
static ilActiveImagePROC ilActiveImage;
static ilActiveLayerPROC ilActiveLayer;
static ilActiveMipmapPROC ilActiveMipmap;
static ilApplyPalPROC ilApplyPal;
static ilApplyProfilePROC ilApplyProfile;
static ilBindImagePROC ilBindImage;
static ilBlitPROC ilBlit;
static ilClearColourPROC ilClearColour;
static ilClearImagePROC ilClearImage;
static ilCloneCurImagePROC ilCloneCurImage;
static ilCompressFuncPROC ilCompressFunc;
static ilConvertImagePROC ilConvertImage;
static ilConvertPalPROC ilConvertPal;
static ilCopyImagePROC ilCopyImage;
static ilCopyPixelsPROC ilCopyPixels;
static ilCreateSubImagePROC ilCreateSubImage;
static ilDefaultImagePROC ilDefaultImage;
static ilDeleteImagesPROC ilDeleteImages;
static ilDisablePROC ilDisable;
static ilEnablePROC ilEnable;
static ilFormatFuncPROC ilFormatFunc;
static ilGenImagesPROC ilGenImages;
static ilGetAlphaPROC ilGetAlpha;
static ilModAlphaPROC ilModAlpha;
static ilSetAlphaPROC ilSetAlpha;
static ilGetBooleanPROC ilGetBoolean;
static ilGetBooleanvPROC ilGetBooleanv;
static ilGetDataPROC ilGetData;
static ilGetDXTCDataPROC ilGetDXTCData;
static ilGetErrorPROC ilGetError;
static ilGetIntegerPROC ilGetInteger;
static ilGetIntegervPROC ilGetIntegerv;
static ilGetLumpPosPROC ilGetLumpPos;
static ilGetPalettePROC ilGetPalette;
static ilGetStringPROC ilGetString;
static ilHintPROC ilHint;
static ilInitPROC ilInit;
static ilIsDisabledPROC ilIsDisabled;
static ilIsEnabledPROC ilIsEnabled;
static ilIsImagePROC ilIsImage;
static ilIsValidPROC ilIsValid;
static ilIsValidFPROC ilIsValidF;
static ilIsValidLPROC ilIsValidL;
static ilKeyColourPROC ilKeyColour;
static ilLoadPROC ilLoad;
static ilLoadFPROC ilLoadF;
static ilLoadImagePROC ilLoadImage;
static ilLoadLPROC ilLoadL;
static ilLoadPalPROC ilLoadPal;
static ilOriginFuncPROC ilOriginFunc;
static ilOverlayImagePROC ilOverlayImage;
static ilPopAttribPROC ilPopAttrib;
static ilPushAttribPROC ilPushAttrib;
static ilRegisterFormatPROC ilRegisterFormat;
static ilRegisterLoadPROC ilRegisterLoad;
static ilRegisterMipNumPROC ilRegisterMipNum;
static ilRegisterNumImagesPROC ilRegisterNumImages;
static ilRegisterOriginPROC ilRegisterOrigin;
static ilRegisterPalPROC ilRegisterPal;
static ilRegisterSavePROC ilRegisterSave;
static ilRegisterTypePROC ilRegisterType;
static ilRemoveLoadPROC ilRemoveLoad;
static ilRemoveSavePROC ilRemoveSave;
static ilResetMemoryPROC ilResetMemory;
static ilResetReadPROC ilResetRead;
static ilResetWritePROC ilResetWrite;
static ilSavePROC ilSave;
static ilSaveFPROC ilSaveF;
static ilSaveImagePROC ilSaveImage;
static ilSaveLPROC ilSaveL;
static ilSavePalPROC ilSavePal;
static ilSetDataPROC ilSetData;
static ilSetDurationPROC ilSetDuration;
static ilSetIntegerPROC ilSetInteger;
static ilSetMemoryPROC ilSetMemory;
static ilSetPixelsPROC ilSetPixels;
static ilSetReadPROC ilSetRead;
static ilSetStringPROC ilSetString;
static ilSetWritePROC ilSetWrite;
static ilShutDownPROC ilShutDown;
static ilTexImagePROC ilTexImage;
static ilTypeFuncPROC ilTypeFunc;
static ilLoadDataPROC ilLoadData;
static ilLoadDataFPROC ilLoadDataF;
static ilLoadDataLPROC ilLoadDataL;
static ilSaveDataPROC ilSaveData;
/*
* Class: org_lwjgl_devil_IL
* Method: ilActiveImage
@ -214,7 +388,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_nilGenImages(JNIEnv *env , jclass
ilGenImages((ILsizei)num, (ILuint *)lists);
}
/*
* Class: org_lwjgl_devil_IL
* Method: ilGetAlpha
@ -657,7 +830,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_ilShutDown(JNIEnv *env, jclass cl
*/
JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_nilTexImage(JNIEnv *env, jclass clazz, jint width, jint height, jint depth , jbyte bpp, jint format, jint type, jobject data_buffer, jint data_offset) {
ILbyte *data = (ILbyte *)(*env)->GetDirectBufferAddress(env, data_buffer);
return ilTexImage((ILuint)width, (ILuint)height, (ILuint)depth , (ILubyte)bpp, (ILenum)format, (ILenum)type, (ILvoid *)(data + data_offset));
}
@ -712,18 +884,22 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilSaveData(JNIEnv *env, jclas
* Method: nCreate
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_nCreate(JNIEnv *env, jclass clazz) {
/*if (!extil_Open(env)) {
JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_nCreate(JNIEnv *env, jclass clazz, jobjectArray ilPaths) {
if (!extil_Open(env, ilPaths)) {
throwException(env, "Failed to load DevIL library");
return;
}*/
}
}
JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_nDestroy(JNIEnv *env, jclass clazz) {
extil_Close();
}
JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_resetNativeStubs(JNIEnv *env, jclass clazz, jclass il_class) {
(*env)->UnregisterNatives(env, il_class);
}
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_initNativeStubs(JNIEnv *env, jclass clazz) {
/*
JavaMethodAndExtFunction functions[] = {
{"ilActiveImage", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilActiveImage, "ilActiveImage", (void*)&ilActiveImage},
{"ilActiveLayer", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilActiveLayer, "ilActiveLayer", (void*)&ilActiveLayer},
@ -747,15 +923,15 @@ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_initNativeStubs(JNIEnv *env, jcla
{"ilEnable", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilEnable, "ilEnable", (void*)&ilEnable},
{"ilFormatFunc", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilFormatFunc, "ilFormatFunc", (void*)&ilFormatFunc},
{"nilGenImages", "(ILjava/nio/IntBuffer;I)V", (void*)&Java_org_lwjgl_devil_IL_nilGenImages, "ilGenImages", (void*)&ilGenImages},
{"ilGetAlpha", "(I)[B", (void*)&Java_org_lwjgl_devil_IL_ilGetAlpha, "ilGetAlpha", (void*)&ilGetAlpha},
{"ilModAlpha", "(I)V", (void*)&Java_org_lwjgl_devil_IL_ilModAlpha, "ilModAlpha", (void*)&ilModAlpha},
{"ilSetAlpha", "(I)V", (void*)&Java_org_lwjgl_devil_IL_ilSetAlpha, "ilSetAlpha", (void*)&ilSetAlpha},
{"ilGetAlpha", "(I)Ljava/nio/ByteBuffer;", (void*)&Java_org_lwjgl_devil_IL_ilGetAlpha, "ilGetAlpha", (void*)&ilGetAlpha},
//{"ilModAlpha", "(I)V", (void*)&Java_org_lwjgl_devil_IL_ilModAlpha, "ilModAlpha", (void*)&ilModAlpha},
//{"ilSetAlpha", "(I)V", (void*)&Java_org_lwjgl_devil_IL_ilSetAlpha, "ilSetAlpha", (void*)&ilSetAlpha},
{"ilGetBoolean", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilGetBoolean, "ilGetBoolean", (void*)&ilGetBoolean},
{"ilGetData", "()[B", (void*)&Java_org_lwjgl_devil_IL_ilGetData, "ilGetData", (void*)&ilGetData},
{"ilGetData", "()Ljava/nio/ByteBuffer;", (void*)&Java_org_lwjgl_devil_IL_ilGetData, "ilGetData", (void*)&ilGetData},
{"ilGetError", "()I", (void*)&Java_org_lwjgl_devil_IL_ilGetError, "ilGetError", (void*)&ilGetError},
{"ilGetInteger", "(I)I", (void*)&Java_org_lwjgl_devil_IL_ilGetInteger, "ilGetInteger", (void*)&ilGetInteger},
{"ilGetLumpPos", "()I", (void*)&Java_org_lwjgl_devil_IL_ilGetLumpPos, "ilGetLumpPos", (void*)&ilGetLumpPos},
{"ilGetPalette", "()[B", (void*)&Java_org_lwjgl_devil_IL_ilGetPalette, "ilGetPalette", (void*)&ilGetPalette},
{"ilGetPalette", "()Ljava/nio/ByteBuffer;", (void*)&Java_org_lwjgl_devil_IL_ilGetPalette, "ilGetPalette", (void*)&ilGetPalette},
{"ilGetString", "(I)Ljava/lang/String;", (void*)&Java_org_lwjgl_devil_IL_ilGetString, "ilGetString", (void*)&ilGetString},
{"ilHint", "(II)V", (void*)&Java_org_lwjgl_devil_IL_ilHint, "ilHint", (void*)&ilHint},
{"ilInit", "()V", (void*)&Java_org_lwjgl_devil_IL_ilInit, "ilInit", (void*)&ilInit},
@ -781,7 +957,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_initNativeStubs(JNIEnv *env, jcla
{"ilSave", "(ILjava/lang/String;)Z", (void*)&Java_org_lwjgl_devil_IL_ilSave, "ilSave", (void*)&ilSave},
{"ilSaveImage", "(Ljava/lang/String;)Z", (void*)&Java_org_lwjgl_devil_IL_ilSaveImage, "ilSaveImage", (void*)&ilSaveImage},
{"nilSaveL", "(ILjava/nio/ByteBuffer;II)I", (void*)&Java_org_lwjgl_devil_IL_nilSaveL, "ilSaveL", (void*)&ilSaveL},
{"ilSavePal", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilSavePal, "ilSavePal", (void*)&ilSavePal},
{"ilSavePal", "(Ljava/lang/String;)Z", (void*)&Java_org_lwjgl_devil_IL_ilSavePal, "ilSavePal", (void*)&ilSavePal},
{"nilSetData", "(Ljava/nio/ByteBuffer;I)Z", (void*)&Java_org_lwjgl_devil_IL_nilSetData, "ilSetData", (void*)&ilSetData},
{"ilSetDuration", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilSetDuration, "ilSetDuration", (void*)&ilSetDuration},
{"ilSetInteger", "(II)V", (void*)&Java_org_lwjgl_devil_IL_ilSetInteger, "ilSetInteger", (void*)&ilSetInteger},
@ -791,14 +967,9 @@ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_initNativeStubs(JNIEnv *env, jcla
{"nilTexImage", "(IIIBIILjava/nio/ByteBuffer;I)Z", (void*)&Java_org_lwjgl_devil_IL_nilTexImage, "ilTexImage", (void*)&ilTexImage},
{"ilTypeFunc", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilTypeFunc, "ilTypeFunc", (void*)&ilTypeFunc},
{"ilLoadData", "(Ljava/lang/String;IIIB)Z", (void*)&Java_org_lwjgl_devil_IL_ilLoadData, "ilLoadData", (void*)&ilLoadData},
{"ilLoadDataL", "(Ljava/nio/ByteBuffer;IIIIIB)Z", (void*)&Java_org_lwjgl_devil_IL_nilLoadDataL, "ilLoadDataL", (void*)&ilLoadDataL},
{"nilLoadDataL", "(Ljava/nio/ByteBuffer;IIIIIB)Z", (void*)&Java_org_lwjgl_devil_IL_nilLoadDataL, "ilLoadDataL", (void*)&ilLoadDataL},
{"ilSaveData", "(Ljava/lang/String;)Z", (void*)&Java_org_lwjgl_devil_IL_ilSaveData, "ilSaveData", (void*)&ilSaveData}
};
int num_functions = NUMFUNCTIONS(functions);
extil_InitializeClass(env, clazz, num_functions, functions);
*/
}
#ifdef __cplusplus
}
#endif

View file

@ -1,4 +1,94 @@
#include "extil.h"
#include "extilu.h"
typedef ILboolean (ILAPIENTRY *iluAlienifyPROC) (ILvoid);
typedef ILboolean (ILAPIENTRY *iluBlurAvgPROC) (ILuint Iter);
typedef ILboolean (ILAPIENTRY *iluBlurGaussianPROC) (ILuint Iter);
typedef ILboolean (ILAPIENTRY *iluBuildMipmapsPROC) (ILvoid);
typedef ILuint (ILAPIENTRY *iluColoursUsedPROC) (ILvoid);
typedef ILboolean (ILAPIENTRY *iluCompareImagePROC) (ILuint Comp);
typedef ILboolean (ILAPIENTRY *iluContrastPROC) (ILfloat Contrast);
typedef ILboolean (ILAPIENTRY *iluCropPROC) (ILuint XOff, ILuint YOff, ILuint ZOff, ILuint Width, ILuint Height, ILuint Depth);
typedef ILvoid (ILAPIENTRY *iluDeleteImagePROC) (ILuint Id);
typedef ILboolean (ILAPIENTRY *iluEdgeDetectEPROC) (ILvoid);
typedef ILboolean (ILAPIENTRY *iluEdgeDetectPPROC) (ILvoid);
typedef ILboolean (ILAPIENTRY *iluEdgeDetectSPROC) (ILvoid);
typedef ILboolean (ILAPIENTRY *iluEmbossPROC) (ILvoid);
typedef ILboolean (ILAPIENTRY *iluEnlargeCanvasPROC) (ILuint Width, ILuint Height, ILuint Depth);
typedef ILboolean (ILAPIENTRY *iluEnlargeImagePROC) (ILfloat XDim, ILfloat YDim, ILfloat ZDim);
typedef ILboolean (ILAPIENTRY *iluEqualizePROC) (ILvoid);
typedef const ILstring (ILAPIENTRY *iluErrorStringPROC) (ILenum Error);
typedef ILboolean (ILAPIENTRY *iluFlipImagePROC) (ILvoid);
typedef ILboolean (ILAPIENTRY *iluGammaCorrectPROC) (ILfloat Gamma);
typedef ILuint (ILAPIENTRY *iluGenImagePROC) (ILvoid);
typedef ILvoid (ILAPIENTRY *iluGetImageInfoPROC) (ILinfo *Info);
typedef ILint (ILAPIENTRY *iluGetIntegerPROC) (ILenum Mode);
typedef ILvoid (ILAPIENTRY *iluGetIntegervPROC) (ILenum Mode, ILint *Param);
typedef const ILstring (ILAPIENTRY *iluGetStringPROC) (ILenum StringName);
typedef ILvoid (ILAPIENTRY *iluImageParameterPROC) (ILenum PName, ILenum Param);
typedef ILvoid (ILAPIENTRY *iluInitPROC) (ILvoid);
typedef ILboolean (ILAPIENTRY *iluInvertAlphaPROC) (ILvoid);
typedef ILuint (ILAPIENTRY *iluLoadImagePROC) (const ILstring FileName);
typedef ILboolean (ILAPIENTRY *iluMirrorPROC) (ILvoid);
typedef ILboolean (ILAPIENTRY *iluNegativePROC) (ILvoid);
typedef ILboolean (ILAPIENTRY *iluNoisifyPROC) (ILclampf Tolerance);
typedef ILboolean (ILAPIENTRY *iluPixelizePROC) (ILuint PixSize);
typedef ILvoid (ILAPIENTRY *iluRegionfvPROC) (ILpointf *Points, ILuint n);
typedef ILvoid (ILAPIENTRY *iluRegionivPROC) (ILpointi *Points, ILuint n);
typedef ILboolean (ILAPIENTRY *iluReplaceColourPROC) (ILubyte Red, ILubyte Green, ILubyte Blue, ILfloat Tolerance);
typedef ILboolean (ILAPIENTRY *iluRotatePROC) (ILfloat Angle);
typedef ILboolean (ILAPIENTRY *iluRotate3DPROC) (ILfloat x, ILfloat y, ILfloat z, ILfloat Angle);
typedef ILboolean (ILAPIENTRY *iluSaturate1fPROC) (ILfloat Saturation);
typedef ILboolean (ILAPIENTRY *iluSaturate4fPROC) (ILfloat r, ILfloat g, ILfloat b, ILfloat Saturation);
typedef ILboolean (ILAPIENTRY *iluScalePROC) (ILuint Width, ILuint Height, ILuint Depth);
typedef ILboolean (ILAPIENTRY *iluScaleColoursPROC) (ILfloat r, ILfloat g, ILfloat b);
typedef ILboolean (ILAPIENTRY *iluSharpenPROC) (ILfloat Factor, ILuint Iter);
typedef ILboolean (ILAPIENTRY *iluSwapColoursPROC) (ILvoid);
typedef ILboolean (ILAPIENTRY *iluWavePROC) (ILfloat Angle);
static iluAlienifyPROC iluAlienify;
static iluBlurAvgPROC iluBlurAvg;
static iluBlurGaussianPROC iluBlurGaussian;
static iluBuildMipmapsPROC iluBuildMipmaps;
static iluColoursUsedPROC iluColoursUsed;
static iluCompareImagePROC iluCompareImage;
static iluContrastPROC iluContrast;
static iluCropPROC iluCrop;
static iluDeleteImagePROC iluDeleteImage;
static iluEdgeDetectEPROC iluEdgeDetectE;
static iluEdgeDetectPPROC iluEdgeDetectP;
static iluEdgeDetectSPROC iluEdgeDetectS;
static iluEmbossPROC iluEmboss;
static iluEnlargeCanvasPROC iluEnlargeCanvas;
static iluEnlargeImagePROC iluEnlargeImage;
static iluEqualizePROC iluEqualize;
static iluErrorStringPROC iluErrorString;
static iluFlipImagePROC iluFlipImage;
static iluGammaCorrectPROC iluGammaCorrect;
static iluGenImagePROC iluGenImage;
static iluGetImageInfoPROC iluGetImageInfo;
static iluGetIntegerPROC iluGetInteger;
static iluGetIntegervPROC iluGetIntegerv;
static iluGetStringPROC iluGetString;
static iluImageParameterPROC iluImageParameter;
static iluInitPROC iluInit;
static iluInvertAlphaPROC iluInvertAlpha;
static iluLoadImagePROC iluLoadImage;
static iluMirrorPROC iluMirror;
static iluNegativePROC iluNegative;
static iluNoisifyPROC iluNoisify;
static iluPixelizePROC iluPixelize;
static iluRegionfvPROC iluRegionfv;
static iluRegionivPROC iluRegioniv;
static iluReplaceColourPROC iluReplaceColour;
static iluRotatePROC iluRotate;
static iluRotate3DPROC iluRotate3D;
static iluSaturate1fPROC iluSaturate1f;
static iluSaturate4fPROC iluSaturate4f;
static iluScalePROC iluScale;
static iluScaleColoursPROC iluScaleColours;
static iluSharpenPROC iluSharpen;
static iluSwapColoursPROC iluSwapColours;
static iluWavePROC iluWave;
/*
* Class: org_lwjgl_devil_ILU
@ -260,9 +350,9 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_devil_ILU_iluGetInteger(JNIEnv *env, jclas
* Method: iluGetIntegerv
* Signature: (ILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_devil_ILU_iluGetIntegerv(JNIEnv *env, jclass clazz, jint mode, jobject param_buffer, jint param_offset) {
JNIEXPORT void JNICALL Java_org_lwjgl_devil_ILU_niluGetIntegerv(JNIEnv *env, jclass clazz, jint mode, jobject param_buffer, jint param_offset) {
ILbyte *lists = (ILbyte *) safeGetBufferAddress(env, param_buffer) + param_offset;
ilGenImages((ILsizei)mode, (ILuint *)lists);
iluGetIntegerv((ILsizei)mode, (ILuint *)lists);
}
/*
@ -356,7 +446,7 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_ILU_iluPixelize(JNIEnv *env, jcl
* Signature: ([Lorg/lwjgl/devil/ILpointf;I)V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_devil_ILU_iluRegionfv(JNIEnv *env, jclass clazz, jobjectArray points, jint n) {
jfieldID fieldId;
/*jfieldID fieldId;
jmethodID methodId;
jobject element;
int i;
@ -392,7 +482,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_devil_ILU_iluRegionfv(JNIEnv *env, jclass
}
printf("\nHere 5");
free(pointInfo);
free(pointInfo);*/
}
/*
@ -409,6 +499,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_devil_ILU_iluRegioniv(JNIEnv *env, jclass
* Signature: (BBBF)Z
*/
JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_ILU_iluReplaceColour(JNIEnv *env, jclass clazz, jbyte red, jbyte green, jbyte blue, jfloat tolerence) {
return false;
}
/*
@ -488,31 +579,65 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_ILU_iluWave(JNIEnv *env, jclass
* Method: nCreate
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_devil_ILU_nCreate(JNIEnv *env, jclass clazz) {
/*if (!extilu_Open(env)) {
JNIEXPORT void JNICALL Java_org_lwjgl_devil_ILU_nCreate(JNIEnv *env, jclass clazz, jobjectArray iluPaths) {
if (!extilu_Open(env, iluPaths)) {
throwException(env, "Failed to load ILU library");
return;
}*/
}
}
JNIEXPORT void JNICALL Java_org_lwjgl_devil_ILU_nDestroy(JNIEnv *env, jclass clazz) {
extilu_Close();
}
JNIEXPORT void JNICALL Java_org_lwjgl_devil_ILU_resetNativeStubs(JNIEnv *env, jclass clazz, jclass ilu_class) {
(*env)->UnregisterNatives(env, ilu_class);
}
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_lwjgl_devil_ILU
* Method: initNativeStubs
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_devil_ILU_initNativeStubs(JNIEnv *env, jclass clazz) {
/*
JavaMethodAndExtFunction functions[] = {
{"iluAlienify", "()Z", (void*)&Java_org_lwjgl_devil_IL_iluAlienify, "iluAlienify", (void*)&iluAlienify},
{"iluAlienify", "()Z", (void*)&Java_org_lwjgl_devil_ILU_iluAlienify, "iluAlienify", (void*)&iluAlienify},
{"iluBlurAvg", "(I)Z", (void*)&Java_org_lwjgl_devil_ILU_iluBlurAvg, "iluBlurAvg", (void*)&iluBlurAvg},
{"iluBlurGaussian", "(I)Z", (void*)&Java_org_lwjgl_devil_ILU_iluBlurGaussian, "iluBlurGaussian", (void*)&iluBlurGaussian},
{"iluBuildMipmaps", "()Z", (void*)&Java_org_lwjgl_devil_ILU_iluBuildMipmaps, "iluBuildMipmaps", (void*)&iluBuildMipmaps},
{"iluColoursUsed", "()I", (void*)&Java_org_lwjgl_devil_ILU_iluColoursUsed, "iluColoursUsed", (void*)&iluColoursUsed},
{"iluCompareImage", "(I)Z", (void*)&Java_org_lwjgl_devil_ILU_iluCompareImage, "iluCompareImage", (void*)&iluCompareImage},
{"iluContrast", "(F)Z", (void*)&Java_org_lwjgl_devil_ILU_iluContrast, "iluContrast", (void*)&iluContrast},
{"iluCrop", "(IIIIII)Z", (void*)&Java_org_lwjgl_devil_ILU_iluCrop, "iluCrop", (void*)&iluCrop},
{"iluDeleteImage", "(I)V", (void*)&Java_org_lwjgl_devil_ILU_iluDeleteImage, "iluDeleteImage", (void*)&iluDeleteImage},
{"iluEdgeDetectE", "()Z", (void*)&Java_org_lwjgl_devil_ILU_iluEdgeDetectE, "iluEdgeDetectE", (void*)&iluEdgeDetectE},
{"iluEdgeDetectP", "()Z", (void*)&Java_org_lwjgl_devil_ILU_iluEdgeDetectP, "iluEdgeDetectP", (void*)&iluEdgeDetectP},
{"iluEdgeDetectS", "()Z", (void*)&Java_org_lwjgl_devil_ILU_iluEdgeDetectS, "iluEdgeDetectS", (void*)&iluEdgeDetectS},
{"iluEmboss", "()Z", (void*)&Java_org_lwjgl_devil_ILU_iluEmboss, "iluEmboss", (void*)&iluEmboss},
{"iluEnlargeCanvas", "(III)Z", (void*)&Java_org_lwjgl_devil_ILU_iluEnlargeCanvas, "iluEnlargeCanvas", (void*)&iluEnlargeCanvas},
{"iluEnlargeImage", "(FFF)Z", (void*)&Java_org_lwjgl_devil_ILU_iluEnlargeImage, "iluEnlargeImage", (void*)&iluEnlargeImage},
{"iluEqualize", "()Z", (void*)&Java_org_lwjgl_devil_ILU_iluEqualize, "iluEqualize", (void*)&iluEqualize},
{"iluErrorString", "(I)Ljava/lang/String;", (void*)&Java_org_lwjgl_devil_ILU_iluErrorString, "iluErrorString", (void*)&iluErrorString},
{"iluFlipImage", "()Z", (void*)&Java_org_lwjgl_devil_ILU_iluFlipImage, "iluFlipImage", (void*)&iluFlipImage},
{"iluGammaCorrect", "(F)Z", (void*)&Java_org_lwjgl_devil_ILU_iluGammaCorrect, "iluGammaCorrect", (void*)&iluGammaCorrect},
{"iluGenImage", "()I", (void*)&Java_org_lwjgl_devil_ILU_iluGenImage, "iluGenImage", (void*)&iluGenImage},
{"iluGetImageInfo", "(Lorg/lwjgl/devil/ILinfo;)V", (void*)&Java_org_lwjgl_devil_ILU_iluGetImageInfo, "iluGetImageInfo", (void*)&iluGetImageInfo},
{"iluGetInteger", "(I)I", (void*)&Java_org_lwjgl_devil_ILU_iluGetInteger, "iluGetInteger", (void*)&iluGetInteger},
//{"niluGetIntegerv", "(ILjava/nio/IntBuffer;)V", (void*)&Java_org_lwjgl_devil_ILU_niluGetIntegerv, "iluGetIntegerv", (void*)&iluGetIntegerv},
{"iluGetString", "(I)Ljava/lang/String;", (void*)&Java_org_lwjgl_devil_ILU_iluGetString, "iluGetString", (void*)&iluGetString},
{"iluImageParameter", "(II)V", (void*)&Java_org_lwjgl_devil_ILU_iluImageParameter, "iluImageParameter", (void*)&iluImageParameter},
{"iluInit", "()V", (void*)&Java_org_lwjgl_devil_ILU_iluInit, "iluInit", (void*)&iluInit},
{"iluInvertAlpha", "()Z", (void*)&Java_org_lwjgl_devil_ILU_iluInvertAlpha, "iluInvertAlpha", (void*)&iluInvertAlpha},
{"iluLoadImage", "(Ljava/lang/String;)I", (void*)&Java_org_lwjgl_devil_ILU_iluLoadImage, "iluLoadImage", (void*)&iluLoadImage},
{"iluMirror", "()Z", (void*)&Java_org_lwjgl_devil_ILU_iluMirror, "iluMirror", (void*)&iluMirror},
{"iluNegative", "()Z", (void*)&Java_org_lwjgl_devil_ILU_iluNegative, "iluNegative", (void*)&iluNegative},
{"iluNoisify", "(F)Z", (void*)&Java_org_lwjgl_devil_ILU_iluNoisify, "iluNoisify", (void*)&iluNoisify},
{"iluPixelize", "(I)Z", (void*)&Java_org_lwjgl_devil_ILU_iluPixelize, "iluPixelize", (void*)&iluPixelize},
{"iluReplaceColour", "(BBBF)Z", (void*)&Java_org_lwjgl_devil_ILU_iluReplaceColour, "iluReplaceColour", (void*)&iluReplaceColour},
{"iluRotate", "(F)Z", (void*)&Java_org_lwjgl_devil_ILU_iluRotate, "iluRotate", (void*)&iluRotate},
{"iluSaturate1f", "(F)Z", (void*)&Java_org_lwjgl_devil_ILU_iluSaturate1f, "iluSaturate1f", (void*)&iluSaturate1f},
{"iluSaturate4f", "(FFFF)Z", (void*)&Java_org_lwjgl_devil_ILU_iluSaturate4f, "iluSaturate4f", (void*)&iluSaturate4f},
{"iluScale", "(III)Z", (void*)&Java_org_lwjgl_devil_ILU_iluScale, "iluScale", (void*)&iluScale},
{"iluScaleColours", "(FFF)Z", (void*)&Java_org_lwjgl_devil_ILU_iluScaleColours, "iluScaleColours", (void*)&iluScaleColours},
{"iluSharpen", "(FI)Z", (void*)&Java_org_lwjgl_devil_ILU_iluSharpen, "iluSharpen", (void*)&iluSharpen},
{"iluSwapColours", "()Z", (void*)&Java_org_lwjgl_devil_ILU_iluSwapColours, "iluSwapColours", (void*)&iluSwapColours},
{"iluWave", "(F)Z", (void*)&Java_org_lwjgl_devil_ILU_iluWave, "iluWave", (void*)&iluWave},
};
int num_functions = NUMFUNCTIONS(functions);
extil_InitializeClass(env, clazz, num_functions, functions);
*/
extilu_InitializeClass(env, clazz, num_functions, functions);
}
#ifdef __cplusplus
}
#endif

View file

@ -1,4 +1,48 @@
#include "extil.h"
#include "extilut.h"
typedef ILboolean (ILAPIENTRY *ilutRendererPROC) (ILenum Renderer);
typedef ILboolean (ILAPIENTRY *ilutDisablePROC) (ILenum Mode);
typedef ILboolean (ILAPIENTRY *ilutEnablePROC) (ILenum Mode);
typedef ILboolean (ILAPIENTRY *ilutGetBooleanPROC) (ILenum Mode);
typedef ILint (ILAPIENTRY *ilutGetIntegerPROC) (ILenum Mode);
typedef const ILstring (ILAPIENTRY *ilutGetStringPROC) (ILenum StringName);
typedef ILvoid (ILAPIENTRY *ilutInitPROC) (ILvoid);
typedef ILboolean (ILAPIENTRY *ilutIsDisabledPROC) (ILenum Mode);
typedef ILboolean (ILAPIENTRY *ilutIsEnabledPROC) (ILenum Mode);
typedef ILvoid (ILAPIENTRY *ilutPopAttribPROC) (ILvoid);
typedef ILvoid (ILAPIENTRY *ilutPushAttribPROC) (ILuint Bits);
typedef ILvoid (ILAPIENTRY *ilutSetIntegerPROC) (ILenum Mode, ILint Param);
typedef GLuint (ILAPIENTRY *ilutGLBindTexImagePROC) ();
typedef GLuint (ILAPIENTRY *ilutGLBindMipmapsPROC) (ILvoid);
typedef ILboolean (ILAPIENTRY *ilutGLBuildMipmapsPROC) (ILvoid);
typedef GLuint (ILAPIENTRY *ilutGLLoadImagePROC) (const ILstring FileName);
typedef ILboolean (ILAPIENTRY *ilutGLScreenPROC) (ILvoid);
typedef ILboolean (ILAPIENTRY *ilutGLScreeniePROC) (ILvoid);
typedef ILboolean (ILAPIENTRY *ilutGLSaveImagePROC) (const ILstring FileName, GLuint TexID);
typedef ILboolean (ILAPIENTRY *ilutGLSetTexPROC) (GLuint TexID);
typedef ILboolean (ILAPIENTRY *ilutGLTexImagePROC) (GLuint Level);
static ilutRendererPROC ilutRenderer;
static ilutDisablePROC ilutDisable;
static ilutEnablePROC ilutEnable;
static ilutGetBooleanPROC ilutGetBoolean;
static ilutGetIntegerPROC ilutGetInteger;
static ilutGetStringPROC ilutGetString;
static ilutInitPROC ilutInit;
static ilutIsDisabledPROC ilutIsDisabled;
static ilutIsEnabledPROC ilutIsEnabled;
static ilutPopAttribPROC ilutPopAttrib;
static ilutPushAttribPROC ilutPushAttrib;
static ilutSetIntegerPROC ilutSetInteger;
static ilutGLBindTexImagePROC ilutGLBindTexImage;
static ilutGLBindMipmapsPROC ilutGLBindMipmaps;
static ilutGLBuildMipmapsPROC ilutGLBuildMipmaps;
static ilutGLLoadImagePROC ilutGLLoadImage;
static ilutGLScreenPROC ilutGLScreen;
static ilutGLScreeniePROC ilutGLScreenie;
static ilutGLSaveImagePROC ilutGLSaveImage;
static ilutGLSetTexPROC ilutGLSetTex;
static ilutGLTexImagePROC ilutGLTexImage;
/*
* Class: org_lwjgl_devil_ILUT
@ -202,25 +246,46 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_ILUT_ilutGLTexImage(JNIEnv *env,
* Method: nCreate
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_devil_ILUT_nCreate(JNIEnv *env, jclass clazz){
/*if (!extilut_Open(env)) {
JNIEXPORT void JNICALL Java_org_lwjgl_devil_ILUT_nCreate(JNIEnv *env, jclass clazz, jobjectArray ilutPaths){
if (!extilut_Open(env, ilutPaths)) {
throwException(env, "Failed to load ILUT library");
return;
}*/
}
}
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT void JNICALL Java_org_lwjgl_devil_ILUT_nDestroy(JNIEnv *env, jclass clazz) {
extilut_Close();
}
JNIEXPORT void JNICALL Java_org_lwjgl_devil_ILUT_resetNativeStubs(JNIEnv *env, jclass clazz, jclass ilut_class) {
(*env)->UnregisterNatives(env, ilut_class);
}
/*
* Class: org_lwjgl_devil_ILUT
* Method: initNativeStubs
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_devil_ILUT_initNativeStubs(JNIEnv *env, jclass clazz){
}
JavaMethodAndExtFunction functions[] = {
{"ilutRenderer", "(I)Z", (void*)&Java_org_lwjgl_devil_ILUT_ilutRenderer, "ilutRenderer", (void*)&ilutRenderer},
{"ilutDisable", "(I)Z", (void*)&Java_org_lwjgl_devil_ILUT_ilutDisable, "ilutDisable", (void*)&ilutDisable},
{"ilutEnable", "(I)Z", (void*)&Java_org_lwjgl_devil_ILUT_ilutEnable, "ilutEnable", (void*)&ilutEnable},
{"ilutGetBoolean", "(I)Z", (void*)&Java_org_lwjgl_devil_ILUT_ilutGetBoolean, "ilutGetBoolean", (void*)&ilutGetBoolean},
{"ilutGetInteger", "(I)I", (void*)&Java_org_lwjgl_devil_ILUT_ilutGetInteger, "ilutGetInteger", (void*)&ilutGetInteger},
{"ilutGetString", "(I)Ljava/lang/String;", (void*)&Java_org_lwjgl_devil_ILUT_ilutGetString, "ilutGetString", (void*)&ilutGetString},
{"ilutInit", "()V", (void*)&Java_org_lwjgl_devil_ILUT_ilutInit, "ilutInit", (void*)&ilutInit},
{"ilutIsDisabled", "(I)Z", (void*)&Java_org_lwjgl_devil_ILUT_ilutIsDisabled, "ilutIsDisabled", (void*)&ilutIsDisabled},
{"ilutIsEnabled", "(I)Z", (void*)&Java_org_lwjgl_devil_ILUT_ilutIsDisabled, "ilutIsDisabled", (void*)&ilutIsDisabled},
{"ilutPopAttrib", "()V", (void*)&Java_org_lwjgl_devil_ILUT_ilutPopAttrib, "ilutPopAttrib", (void*)&ilutPopAttrib},
{"ilutPushAttrib", "(I)V", (void*)&Java_org_lwjgl_devil_ILUT_ilutPushAttrib, "ilutPushAttrib", (void*)&ilutPushAttrib},
{"ilutSetInteger", "(II)V", (void*)&Java_org_lwjgl_devil_ILUT_ilutSetInteger, "ilutSetInteger", (void*)&ilutSetInteger},
#ifdef __cplusplus
{"ilutGLBindTexImage", "()I", (void*)&Java_org_lwjgl_devil_ILUT_ilutGLBindTexImage, "ilutGLBindTexImage", (void*)&ilutGLBindTexImage},
{"ilutGLBindMipmaps", "()I", (void*)&Java_org_lwjgl_devil_ILUT_ilutGLBindMipmaps, "ilutGLBindMipmaps", (void*)&ilutGLBindMipmaps},
{"ilutGLBuildMipmaps", "()Z", (void*)&Java_org_lwjgl_devil_ILUT_ilutGLBuildMipmaps, "ilutGLBuildMipmaps", (void*)&ilutGLBuildMipmaps},
{"ilutGLLoadImage", "(Ljava/lang/String;)I", (void*)&Java_org_lwjgl_devil_ILUT_ilutGLLoadImage, "ilutGLLoadImage", (void*)&ilutGLLoadImage},
{"ilutGLScreen", "()Z", (void*)&Java_org_lwjgl_devil_ILUT_ilutGLScreen, "ilutGLScreen", (void*)&ilutGLScreen},
{"ilutGLScreenie", "()Z", (void*)&Java_org_lwjgl_devil_ILUT_ilutGLScreenie, "ilutGLScreenie", (void*)&ilutGLScreenie},
{"ilutGLSaveImage", "(Ljava/lang/String;I)Z", (void*)&Java_org_lwjgl_devil_ILUT_ilutGLSaveImage, "ilutGLSaveImage", (void*)&ilutGLSaveImage},
{"ilutGLSetTex", "(I)Z", (void*)&Java_org_lwjgl_devil_ILUT_ilutGLSetTex, "ilutGLSetTex", (void*)&ilutGLSetTex},
{"ilutGLTexImage", "(I)Z", (void*)&Java_org_lwjgl_devil_ILUT_ilutGLTexImage, "ilutGLTexImage", (void*)&ilutGLTexImage},
};
int num_functions = NUMFUNCTIONS(functions);
extilut_InitializeClass(env, clazz, num_functions, functions);
}
#endif