DevIL - What's wrong here?

I’m making an attempt at using DevIL for loading textures, but whenever I call IL.create(), it throws this:

org.lwjgl.LWJGLException: Could not load devil library.
        at org.lwjgl.devil.ILNative.nCreateIL(Native Method)
        at org.lwjgl.devil.ILNative.createIL(ILNative.java:98)
        at org.lwjgl.devil.IL.create(IL.java:583)
        at DevIL_test.<init>(DevIL_test.java:7)
        at DevIL_test.main(DevIL_test.java:15)

It sounds to me like it cannot locate lwjgl-devil.dll. But what have I done wrong?

Here’s where I put my DevIL JARs (for compilation, works pefect):
C:\j2sdk1.4.0\lib
C:\j2sdk1.4.0\jre\lib
C:\j2sdk1.4.0\jre\lib\ext
C:\Program Files\Java\jre1.5.0_06\lib
C:\Program Files\Java\jre1.5.0_06\lib\ext

And here’s where I put my DevIL DLLs (for runtime, throws exception):
C:\j2sdk1.4.0\jre\bin
C:\Program Files\Java\jre1.5.0_06\bin

Here’s my code (just a quick test):

import org.lwjgl.devil.IL;
import org.lwjgl.LWJGLException;

public class DevIL_test {
	public DevIL_test() {
		try {
			IL.create();
		} catch(LWJGLException e) {
			e.printStackTrace();
			System.exit(-1);
		}
	}

	public static void main(String args[]) {
		new DevIL_test();
	}
}

I’d really appreciate some help here. I’m stumped.

Thanks,
Jamison

Hey it’s me! The idiot who can’t figure out how to look at other peoples topics and use the search feature before posting a question… http://www.java-gaming.org/forums/index.php?topic=7041.0

I just copied DevIL.dll into my working directory, and it works now.

never ever use jre/ext unless you’re deploying a JRE (well, unless you have a very good reason)

Okay, thanks.

Anyhow, now that I fixed the “Could not load devil library,” I recieve another error after creating a texture with DevIL. Here’s the code for loading my texture:

	private void GenerateTexture(String file) {
		try {
			IL.create();
		} catch(LWJGLException e) {
			e.printStackTrace();
			System.exit(-1);
		}

		IntBuffer image = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
		IL.ilGenImages(image);
		IL.ilBindImage(image.get(0));
		IL.ilLoadImage(file);
		IL.ilConvertImage(IL.IL_RGB, IL.IL_BYTE);
		ByteBuffer scratch = ByteBuffer.allocateDirect(IL.ilGetInteger(IL.IL_IMAGE_WIDTH) * IL.ilGetInteger(IL.IL_IMAGE_HEIGHT) * 3);
		IL.ilCopyPixels(0, 0, 0, IL.ilGetInteger(IL.IL_IMAGE_WIDTH), IL.ilGetInteger(IL.IL_IMAGE_HEIGHT), 1, IL.IL_RGB, IL.IL_BYTE, scratch);

		IntBuffer buf = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
		GL11.glGenTextures(buf);

		GL11.glBindTexture(GL11.GL_TEXTURE_2D, buf.get(0));

		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
		GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, IL.ilGetInteger(IL.IL_IMAGE_WIDTH), IL.ilGetInteger(IL.IL_IMAGE_HEIGHT), 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, scratch);

		texture = buf.get(0);
	}

I made sure this was called after creating the display, but it throws the following:

Exception in thread "main" org.lwjgl.opengl.OpenGLException: Invalid value (1281
)
        at org.lwjgl.opengl.Util.checkGLError(Util.java:56)
        at org.lwjgl.opengl.Display.swapBuffers(Display.java:567)
        at org.lwjgl.opengl.Display.update(Display.java:583)
        at Example.UpdateLoop(Example.java:65)
        at Example.<init>(Example.java:22)
        at Example.main(Example.java:80)

PLEASE HELP ME! This LWJGL stuff is really hurting my head… I’ve come accross so many problems with LWJGL - problems I would never come accross with Java 2D :’(.

first of all there is a BufferUtils class
secondly, the issues you have is not with LWJGL - it’s with Devil and OpenGL, and from a lack of understanding of the APIs

Start with the red book and nehe tutorials:
http://www.gamedev.net/download/redbook.pdf
http://nehe.gamedev.net/

The issue you are getting is because you supplied an invalid value to an OpenGL function.
If you throw in some org.lwjgl.opengl.Util.checkGLError’s here and there, you will find the offending line. Read op on the method and what arguments it accepts.

I sure will. But also, here’s the weird thing… I never got that error message until I loaded my textures with DevIL, and I’ve pinpointed that the problem is somewhere in this line:

GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, IL.ilGetInteger(IL.IL_IMAGE_WIDTH), IL.ilGetInteger(IL.IL_IMAGE_HEIGHT), 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, scratch);

(I commented that line out, and then I didn’t get the error message, but of course the texture won’t work without this line.)

Hint: you are passing GL11.GL_RGB twice… that’s not a good thing. What Matzon said, get to know the OpenGL call you’re making, what is valid as input etc.

Bill