I'm trying to make a simple button in OpenGL/LWJGL,
I can render my 2D QUAD correctly, but when i implement the texture, only about 3/4 parts of the whole quad gets textured, like this: https://dl.dropboxusercontent.com/u/60223805/glerror1.png
and if i remove the texture coords i get this: https://dl.dropboxusercontent.com/u/60223805/glerror2.png
none.bind();
co.Enable2D_GUI();
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0, 0);
GL11.glVertex2f(co.width/2-200, co.height/2);
GL11.glTexCoord2f(1, 0);
GL11.glVertex2f(co.width/2+none.getTextureWidth(),co.height/2);
GL11.glTexCoord2f(1, 1);
GL11.glVertex2f(co.width/2+none.getTextureWidth(), co.height/2+none.getTextureHeight());
GL11.glTexCoord2f(0, 1);
GL11.glVertex2f(co.width/2-200, co.height/2+none.getTextureHeight());
GL11.glEnd();
co.Disable2D_GUI();
where none is an Texture (from slick-util library) and the functions Enable2D_GUI and Disable2D_GUI just enables and disable ortho and stuff.
What can be wrong? I'm very new to OpenGL so im sorry if my question is a bit nooby
This is my Enable2D_GUI and Disable2D_GUI functions:
public void Enable2D_GUI() {
GL11.glMatrixMode (GL11.GL_PROJECTION);
GL11.glPushMatrix();
GL11.glLoadIdentity ();
GL11.glOrtho (0, width, height, 0, 1, -1);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glMatrixMode (GL11.GL_MODELVIEW);
GL11.glPushMatrix();
GL11.glLoadIdentity();
}
public void Disable2D_GUI() {
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
Now when I test it with a 3D QUAD it doesnt work either, same result. This is my OpenGL init code:
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glClearColor(0f, 0.0f, 0.0f, 0.0f);
GL11.glClearDepth(1.0);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDepthFunc(GL11.GL_LEQUAL);
GL11.glViewport(0, 0, width, height);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GLU.gluPerspective(
45.0f,
(float)width/(float)height,
0.5f,
50.0f);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);