LWJGL question:
im now writing a code which add a texture to a quad
Other then that, I've also seen ppl doing THIS:
Assume i input 64,64 to the second code as x y parameters, why is the x y in glVertex2f be 0 , width and height at first? Shouldn't it be x,y, x or y + width and x or y + height?
Like normally 0xy should be the top left corner of the computer. But now it changed to the top left corner of the quad. Is that what glTranslatef does?
im now writing a code which add a texture to a quad
Code
public static void DrawQuadTex(Texture texture, float x, float y, float width, float height) {
texture.bind();
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex2f(x,y);
glTexCoord2f(1,0);
glVertex2f(x+width,y);
glTexCoord2f(1,1);
glVertex2f(x+width, y+height);
glTexCoord2f(0,1);
glVertex2f(x,y+ height);
glEnd();
glLoadIdentity();
}Code
public static void DrawQuadTex(Texture texture, float x, float y, float width, float height) {
texture.bind();
glTranslatef(x,y,0);
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex2f(0,0);
glTexCoord2f(1,0);
glVertex2f(width,y);
glTexCoord2f(1,1);
glVertex2f(width, height);
glTexCoord2f(0,1);
glVertex2f(0,height);
glEnd();
glLoadIdentity();
}Assume i input 64,64 to the second code as x y parameters, why is the x y in glVertex2f be 0 , width and height at first? Shouldn't it be x,y, x or y + width and x or y + height?
Like normally 0xy should be the top left corner of the computer. But now it changed to the top left corner of the quad. Is that what glTranslatef does?


