Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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. –  Mr. 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
add comment

Your Answer


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

Browse other questions tagged or ask your own question.