Re: Trouble with TextureCoords for tilesets
Posted by
goosey on
Mar 19, 2021; 4:00pm
URL: https://forum.jogamp.org/Trouble-with-TextureCoords-for-tilesets-tp4041047p4041051.html
I have found the answer to my problem!

It turns out that I was doing glTexCoord2f()
AFTER I did glVertex2f().
The code now looks like this:
// Draw the image
texture.enable(gl);
texture.bind(gl);
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(tc.left(), tc.top());
gl.glVertex2f(x, y);
gl.glTexCoord2f(tc.left(), tc.bottom());
gl.glVertex2f(x, y + height);
gl.glTexCoord2f(tc.right(), tc.bottom());
gl.glVertex2f(x + width, y + height);
gl.glTexCoord2f(tc.right(), tc.top());
gl.glVertex2f(x + width, y);
gl.glEnd();
texture.disable(gl);