# How to use traditional pixel coordinates system in OpenGL? (with C++/SDL2)

I find the normalized, centralized coordinate system used in OpenGL weird and annoying, is there anything I can do at all to make it work like normal pixel coordinates on everything ever except OpenGL? And yes, of course I Googled it.

EDIT: I'm using OpenGL 2.1

• Yeah, you have full control over the matrix that converts world coordinates to screen coordinates. You can do whatever you want to. If you say specifically what type of coordinate system you are looking to have, and what version or type of opengl you are using, someone might even be able to help you do it – Alan Wolfe Jul 22 '15 at 2:12
• i said the coordinate system i wanted to have in my question "normal pixel coordinates on everything ever except OpenGL" you know, (0,0) = top left to (w,h) = bottom right – Accumulator Jul 22 '15 at 2:15

## 1 Answer

glOrtho( 0.f, viewWidth, viewHeight, 0.f, 0.f, 1.f );

Assuming that you're starting from an identity matrix, this glOrtho() call will give you a traditional window coordinate system with 0,0 at the top left corner, such that one unit in OpenGL space corresponds exactly to one pixel in the view which contains the OpenGL-rendered image.

Man page for glOrtho.

• Can this create some performance issues for OpenGL? – Xriuk May 22 '16 at 16:44
• No. This is just changing the values used in a coordinate conversion calculation that was being done anyway. If you don't convert the things you're drawing into this new pixel-based coordinate system then those things could be drawn larger or smaller than before, or more or fewer things could be drawn than before, and that could have performance implications. But by and large, this is just changing the constants in a couple maths operations, and won't speed up or slow down anything at all. – Trevor Powell May 23 '16 at 0:30