There is a problem with rotation of 180 degrees, this not only affects the direction of your Y coordinate, but also on X.
YX <- +
^ => |
| v
+ -> XY
What you probably wanted to do was translate the point to Y and then invert the Y coordinate. You can do it like this:
- Convert Y to a new origin
- Scale (1, -1)
Y + -> X
^ => |
| v
+ -> XY
Thinking again, I have to wonder why you are doing this conversion in the first place? Is it due to differences in the OpenGL coordinates and the Qt coordinates for its window?
If so, you can change the projection matrix ... If you use a spelling matrix, for example:
Try glOrtho (0, X, 0, Y, -1, 1); instead of the traditional glOrtho (0, X, Y, 0, -1, 1);
If you decide to do this, you probably need to change the winding direction of your polygon faces. OpenGL defaults to CCW, change it to glFrontFace (GL_CW) , and this should prevent strange lighting / rejection behavior.
source share