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

  • \$\begingroup\$ 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 \$\endgroup\$ – Alan Wolfe Jul 22 '15 at 2:12
  • 2
    \$\begingroup\$ 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 \$\endgroup\$ – Accumulator Jul 22 '15 at 2:15

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.

| improve this answer | |
  • \$\begingroup\$ Can this create some performance issues for OpenGL? \$\endgroup\$ – Xriuk May 22 '16 at 16:44
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ – Trevor Powell May 23 '16 at 0:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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