Non power of two textures and modern versions of OpenGL

Started by Miodhchion, July 31, 2009, 16:00:55

Previous topic - Next topic

Miodhchion

I'm sorry if I'm asking some silly questions here. I've done a little OpenGL work in C++, but I'm totally new to OpenGL in Java and LWJGL. I've been trying to modify things from the NeHe tutorials to suit my application and it seems to work to work fine except for some unusual sized textures.

OpenGL 3.0 supposedly supports non-power-of-2 textures, and LWJGL 2.1 supports OpenGL 3, so I assume there's a way to use these textures. Can someone point me in the right direction regarding how to do that? I know I could split my textures into pieces or pad them to a larger size and only map part of that to an object, but it sure would be convenient to use the textures I have.

Thanks!

spasi

NPOT textures is an OpenGL 2.0 feature actually. Which means that if the OpenGL version is 2.0 or higher, or the ARB_texture_non_power_of_two extension is exposed, you can simply use the TEXTURE_2D target with NPOT textures, it will simply work.

e.g. glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, 400, 300, 0, format, type);

You're also right that this has nothing to do with LWJGL/Java or C++, it's an OpenGL specification thingy.

Miodhchion

Thanks for the advice. Turns out my problem wasn't Java, LWJGL or OpenGL, but a file loading routine that was "helpfully" padding my textures to powers of two.