Skip to content

Instantly share code, notes, and snippets.

@tuttlem
Created December 1, 2012 06:56
Show Gist options
  • Save tuttlem/4180890 to your computer and use it in GitHub Desktop.
Save tuttlem/4180890 to your computer and use it in GitHub Desktop.
OpenGL2D - setup
/* first of all, we need to read the dimensions of the
display viewport. */
int viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
/* setup an orthographic matrix using the viewport
dimensions on the projection matrix */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, viewport[2], viewport[3], 0, -1, 1);
/* clear out the modelview matrix */
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
/* disable depth testing (as we're not using z) */
glDisable(GL_DEPTH_TEST);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment