LWJGL basic problem with texture

Hello.
I decide to learn LWJGL and now after few basic tutorials I wont to load my first texture.
My first step was copy paste this code
http://lwjgl.org/wiki/index.php?title=Slick-Util_Library_-Part_1-_Loading_Images_for_LWJGL
and unfortunately I have problem namely
http://img546.imageshack.us/img546/6348/picsk.png
as you can see there are some strength line.
Size loaded texture is 40x40 and system out


>> Image width: 40
>> Image height: 40
>> Texture width: 64
>> Texture height: 64
>> Texture ID: 1

for me it looks like object texture is too big but I could be wrong, so how to fix this?

What’s it supposed to look like?

Cas :slight_smile:

You’re using a non power of two texture, which isn’t supported by opengl like you are using it.

Just use textures which are power of two sizes is the simplest solution. A bit more fiddling is needed to support non power of two textures but it is possible.

Its a common problem people run into when starting with opengl, just google for it, plenty of solutions out there.

Without this blue line in yellow circles
http://img849.imageshack.us/img849/5126/pic1cu.png

kappa
I found, thanks.

  • The texture loader you use makes the resulting texture dimensions a power of two.
  • The lines are due to filtering. The standard wrap setting is GL_REPEAT which means that if you were to send in a texture coordinate that is higher than 1.0 or lower than 0.0 then it would simply repeat the texture multiple times over the triangle. This combined with linear filtering causes the right edge to possible get mixed together with the left edge even if you have texture coordinates that are NOT over 1.0 or under 0.0 due to bilinear filtering catching the closest 4 texture samples and mixing them. In your case simply changing the wrap mode to GL_CLAMP_TO_EDGE (in GL12) which is a special wrap mode that disallows any wrapping between the texture edges.

Wrong since 2003. Support for NPOT textures is even integrated in core in OpenGL 2.0.

No fiddling at all if you do manual loading. Just don’t calculate power of two dimensions and supply the data just like normal to glTex2D. Where’s the fiddling? Okay, you do have to keep your dimension sizes to multiples of 4 unless you write a single line to change unpack alignment to 1. -_- This also saves memory.

Sure, but my reply is referring to how akzyl was trying to make it work (his code only uses OpenGL 1.1).

However he is not manually loading it but using Slick-Util which does require some fiddling :slight_smile: