loading textures

Hello.
I’m learning with NeHe tutorials and I’ve come to loading textures. LWJGL port that CaptainJester wrote uses DevIL, but DevIL has lost support as I know and has some problems across platforms as I’ve read on lwjgl forums. My question is how to load textures now? I know how to use ImageIO and load and image… but in what format they need to be? Do I need to make some modifications on it after it is loaded or can I just use glBindTexture()? Also I’ve read that TGA is best solution for storing images for games, since it has fastest loading time. True?
Thank you.

just convert any image to ARGB or BGRA, put it in a ByteBuffer and upload it, just like in the NeHe tutorials.

I’ve found a neat solution… used Texture, TextureLoader classes from Kev’s space invaders tutorial. All you need to do is:

Texture = TextureLoader.getTexture(path); (note: it’s not really static, just abstraction)

and

Texture.bind()

later

But I have one problem… App crashes when using GL_LINEAR_MIPMAP_NEAREST as GL_TEXTURE_MIN_FILTER. If I comment following code it works fine, this is advanced (overloaded) getTexture().


           texture[2] = texture_loader.getTexture("Data/Crate.bmp",
                   GL11.GL_TEXTURE_2D,
                   GL11.GL_RGBA,
                   GL11.GL_LINEAR,
                   GL11.GL_LINEAR_MIPMAP_NEAREST);

Exception is thrown on Display.update(). Anybody knows why? Google wasn’t too helpful. Thank you.


org.lwjgl.opengl.OpenGLException: Invalid enum (1280)
	at org.lwjgl.opengl.Util.checkGLError(Util.java:56)
	at org.lwjgl.opengl.Display.swapBuffers(Display.java:555)
	at org.lwjgl.opengl.Display.update(Display.java:571)
	at Lesson07.run(Lesson07.java:82)
	at Lesson07.main(Lesson07.java:72)

Exception was because I can’t use mipmap on MAG filter (not MIN filter as I wrote the first time)… people told me that it’s logical but I’m a noob in opengl and don’t see that :slight_smile: Shame Exception is thrown on Display.update() instead of apply filter statement.