OpenGL Loading Texture (LWJGL)

Greetings.

So I decided to try learning OpenGL (again), and… for some reason am using Java, and thus LWJGL.

It went well for a while, but I am quite stuck on getting a texture to display.

http://pastebin.com/CfsnEFYr

I feel it is something small, but it has not become apparent to me over 12 hours, so I decided to come for help.

The image loads successfully. glGetError returns 0 (and glGenTextures returns 1 (not 0), if it matters).

I tried glTextCoordx at some point, but to no avail.

It is my understanding that there are several steps:

First, enable textures, and set several parameters (glTexParameteri).

Get an id for a new texture.

“upload” the data for it (I had a lot of trouble with this step. In the current configuration, it no longer errors with 1280 though (invalid enum)).

Bind it.

Draw stuffs.

Unbind it.

I also tried it with binding before the upload, as it seems it does not take a handle/id, but rather affects the current bound texture. No success.

What am I missing?

http://www.java-gaming.org/topics/lwjgl-tutorial-series-textures/30680/msg/283521/view.html

That was what I was trying to follow, yes. If I use the vertices and texture coordinates provided, it still does not use the texture.

Do you think I should use the exact code of the tutorial, to see if it works, then modify?

Yes you should use the exact code. That’s why its a tutorial. I use it all the time, it works fine.

Ok. Tried that. With some modifications (file loading was amiss, and the videomode creation crashed it), it works.

Theoretically I can keep this close and try it again on the side, and see which steps I am missing. Hopefully I get it working.

Did you, when learning, have difficulties with glTexImage2D? It feels rather fragile, I am not positive when the data is correct or not.

No I didn’t, it really is kind of straight forward. Just take a look at the LWJGL docs and look at all the parameters and really learn what they mean, you’ll get it after you study it for a few minutes!

Besides, I wrote my texture class once and have never had to mess with it again. Once you get texture loading working, you really don’t have to mess with it again. So just make it work and never look back unless you have issues!

Nope. If something goes wrong you’ll either get an error (you do call glGetError() regularly, right?) or crash the VM.

The most common reason for textures “not loading” is forgetting to set the filtering mode. By default OpenGL expects mipmaps, so you need to either set the max mipmap level (GL_TEXTURE_MAX_LEVEL) or change the min filtering mode (GL_TEXTURE_MIN_FILTER) to a mode that doesn’t require mipmaps. Just a hint…