Orthogonal projection and texture coordinates in opengl

Posted by knuck on Stack Overflow See other posts from Stack Overflow or by knuck
Published on 2010-05-04T05:57:15Z Indexed on 2010/05/04 6:08 UTC
Read the original article Hit count: 346

I'm writing a 2D game in Opengl. I already set up the orthogonal projection so I can easily know where a quad will end up on screen. The problem is, I also want to be able to map pixels directly to texture coords, so I also applied an orthogonal transformation (using gluOrtho2d) to the texture. Now I can map pixels directly using integers and glTexCoord2i. The thing is, after googling/reading/asking, I found out no one really knows (apparently) the behavior of glTexCoord2i, but it works just fine the way I'm using. Some sample test code I wrote follows:

glBegin(GL_QUADS);
    glTexCoord2i(16,0);
    glVertex2f(X, Y);
    glTexCoord2i(16,16);
    glVertex2f(X, Y+32);
    glTexCoord2i(32, 16);
    glVertex2f(X+32, Y+32);
    glTexCoord2i(32, 0);
    glVertex2f(X+32, Y);
glEnd();

So, is there any problem with what I'm doing, or is what I'm doing correct?

© Stack Overflow or respective owner

Related posts about opengl

Related posts about projection