Skip to content

Instantly share code, notes, and snippets.

@flexd
Created March 4, 2012 01:57
Show Gist options
  • Save flexd/1969955 to your computer and use it in GitHub Desktop.
Save flexd/1969955 to your computer and use it in GitHub Desktop.
// top left
glTexCoord2f(tileX * tileWidth / ftexWidth, tileY * tileHeight / ftexHeight);
glVertex2i(x, y);
// top right
glTexCoord2f((tileX + 1) * tileWidth / ftexWidth, tileY * tileHeight / ftexHeight);
glVertex2i(x + tileWidth, y);
// bottom right
glTexCoord2f((tileX + 1) * tileWidth / ftexWidth, (tileY + 1) * tileHeight / ftexHeight);
glVertex2i(x + tileWidth, y + tileHeight);
// bottom left
glTexCoord2f(tileX * tileWidth / ftexWidth, (tileY + 1) * tileHeight / ftexHeight);
glVertex2i(x, y + tileHeight);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment