having 0,0 at upper left corner after a rotate ?

Was not sure to post in math or here but lets have a try here.

usually when u want to have the origin coordinate (0,0) in the upper left corner, Y looking down, (instead of the default “center of screen Y looking up” coordinate system), you just call:

glOrthof(0, width, height, 0, -1, 1),

But in my case i need first to do a 90 rotation (iphone lansacape mode). New code becomes:

glRotatef(90.0, 0.0, 0.0, 1.0);
glOrthof(0, width, height, 0, -1, 1);

this doesnt work because after the 90 degree rotation my upper left corner becomes the lower left corner (if you rotate the rectangle its quiet obvious).

My question is:
what kind of transformation shall i do (after the glRotate) to keep my original current system (0,0 at upper left, Y looking down)…

i guess its obvious when you know math behind opengl but i dont understand them …

I think you’ll need something like


glScalef(1.0f, -1.0f, 1.0f);
glTranslatef(0.0f, height, 0.0f);

applied to your projection. The translation effectively shifts the origin up to the left-hand corner, and the scale flips the positive y-direction.

  • Chris

This seems to work perfecty;
however i am sure you could it with a single ortho … anyway many thanks