I'm having problems with texturing in LWJGL. The texture is not being stretched to a quad. As you can see, the texture is not being sized to the quad, marked with pink border. The problem doesn't exist when using square quad and square texture. Scaling the texture to 960x320 px doesn't help The texture size is 96px width and 32px height.(1 tile is 32x32, this object is 3 by 1)
The code:
//rendering the textured quad. This method also renders everything else
public static void renderTile(Texture tex, int x, int y, int sizex, int sizey) {
tex.bind();
glBegin(GL_QUADS);
glColor4f(1, 1, 1, 1);
glTexCoord2f(0, 0);
glVertex2f(x, y);
glTexCoord2f(1, 0);
glVertex2f(x + sizex, y);
glTexCoord2f(1, 1);
glVertex2f(x + sizex, y + sizey);
glTexCoord2f(0, 1);
glVertex2f(x, y + sizey);
glEnd();
}
//opengl initialization code, called before any rendering
public static void initOGL(){
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 800, 600, 0 , 1, -1);
Log.info("Display W=" + Display.getWidth() + " H=" + Display.getHeight());
glMatrixMode(GL_MODELVIEW);
glEnable(GL_TEXTURE_2D);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}