Problem with slick-util texture loading - graphical glitches

Started by semicolon7, July 10, 2012, 02:56:39

Previous topic - Next topic

semicolon7

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, 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). 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?

moci

Can you upload the image file? I just ran the demo code and it worked fine with my image.

Fool Running

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.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

semicolon7

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();