LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: semicolon7 on July 10, 2012, 02:56:39

Title: Problem with slick-util texture loading - graphical glitches
Post by: semicolon7 on July 10, 2012, 02:56:39
I'm using code literally copied and pasted from http://www.lwjgl.org/wiki/index.php?title=Slick-Util_Library_-_Part_1_-_Loading_Images_for_LWJGL (http://www.lwjgl.org/wiki/index.php?title=Slick-Util_Library_-_Part_1_-_Loading_Images_for_LWJGL), but when I draw my test image (a box with the word "Test") inside it, I'm getting weird graphical artifacts underneath the image (http://imgur.com/Hkzkh (http://imgur.com/Hkzkh)). Further investigation revealed that the image height was correct, but the texture height continues to the bottom of the artifact. What's going on here, and how can I fix it?
Title: Re: Problem with slick-util texture loading - graphical glitches
Post by: moci on July 10, 2012, 10:05:05
Can you upload the image file? I just ran the demo code and it worked fine with my image.
Title: Re: Problem with slick-util texture loading - graphical glitches
Post by: Fool Running on July 10, 2012, 12:42:52
It looks to me like the image is mirrored (maybe caused by a non power-of-two texture stretched too far). Try replacing the texture coordinates that are a "1" with texture.getHeight() and texture.getWidth() in the appropriate places.
Title: Re: Problem with slick-util texture loading - graphical glitches
Post by: semicolon7 on July 10, 2012, 14:38:28
Changing 1 to texture.getWidth()/texture.getHeight() almost worked, and it was close enough that I could figure out what else I had to change. The drawing code ended up looking like this:
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex2f(100,100);
glTexCoord2f(texture.getWidth(),0);
glVertex2f(100+texture.getTextureWidth(),100);
glTexCoord2f(texture.getWidth(),texture.getHeight());
glVertex2f(100+texture.getTextureWidth(),100+texture.getImageHeight());
glTexCoord2f(0,texture.getHeight());
glVertex2f(100,100+texture.getImageHeight());
glEnd();