Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm building a 2D engine based on 32x32 tiles with OpenGL. OpenGL draws from the top left, so Y coordinates go down the screen as they increase. Obviously this is different than a standard graph where Y coordinates move up as they increase.

I'm having trouble determining how I want to track positions for both sprites and tile objects (objects that are collections of tiles). My brain wants to set the world position as the bottom left of the object and track every object this way. The problem with this is I would have to translate it to an on screen position on rendering. The positive with this is I could easily visualize (especially in the case of objects made of multiple tiles) how something is structured and needs to be built.

Are there standard ways for doing this? Should I just suck it up and get used to positions beginning in the top left?

Here are the OpenGL calls to start rendering:

// enable textures since we're going to use these for our sprites
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

// enable alpha blending

// disable the OpenGL depth test since we're rendering 2D graphics

glOrtho(0, WIDTH, HEIGHT, 0, 1, -1);

I assume I need to change:

glOrtho(0, WIDTH, HEIGHT, 0, 1, -1);


glOrtho(0, WIDTH, 0, HEIGHT, 1, -1);
share|improve this question
OpenGL lets you set up the coordinate system just how you want it. If you look at glOrtho it should be quite straightforward how to do it. – API-Beast Jun 12 '12 at 20:03
Edited to include that part of the code. If you want to supply the answer I'll mark it as correct (if I can... not sure if I have enough rep yet). – Magicked Jun 12 '12 at 20:27

There isn't a standard way to do this; each game or engine will (and should) elect to use the coordinate model that makes the most sense for it.

That said, it's generally standard practice to normalize the coordinate model, so everything works the same where viable (it makes it easier to think about). That means it's generally better to have your logical world origin and rendering origins align (in the lower left or upper left, for example).

Most 3D APIs provide mechanisms to support this through the configuration of the projection matrices or similar. As you speculated, if you are using orthographic projection in OpenGL, you can just flip the parameters to glOrtho accordingly to adjust how your coordinate system appears.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.