I have a Tilesheet loaded as a texture and I am trying to render a single tile from the texture
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glBindTexture(GL_TEXTURE_2D, TileSheet);
float TY = (Tile / 16) * 0.0625;
float TX = (Tile % 16) * 0.0625;
glBegin(GL_QUADS);
glTexCoord2f(TX, TY); glTexCoord2f(0, 0); glVertex3f(X, Y, 0);
glTexCoord2f(TX + 0.0625, TY); glVertex3f(X + TILE_SIZE, Y, 0);
glTexCoord2f(TX + 0.0625, TY + 0.0625); glVertex3f(X + TILE_SIZE, Y + TILE_SIZE, 0);
glTexCoord2f(TX, TY + 0.0625); glVertex3f(X, Y + TILE_SIZE, 0);
glEnd();
Tile is an int and represents what tile to render on the tilesheet
0.0625 being Width and Height of my Tilesheet / How many tiles per line (512 / 16)
So in the tilesheet it is 16 tiles wide so if Tile was 16 it would be the tile on the left and one tile from the top of the tilesheet. But this is what I get 
So the top left is [0][0] and the bottom right is [1][0] I dont see what im doing wrong. any help would be greatly appreciated.
Thanks.
I should also mention that if Tile == 0 it renders the correct tile, but as soon as Tile > 0 the tile ends up as above.
You call
glTexCoord2ftwice before you callglVertex3f. That does not look right.It looks like this line:
glTexCoord2f(TX, TY); glTexCoord2f(0, 0); glVertex3f(X, Y, 0);Should be:
glTexCoord2f(TX, TY); glVertex3f(X, Y, 0);