PDA

View Full Version : how to change coordinate system to screen coordinates (0,0 at UpperLeft) ?



Martin_unique
03-03-2003, 08:22 AM
Hello,
I tried to modify the modelview matrix by multiplying it by a modified identity matrix (y coord was -1 instead of 1 to inverse y coordinates) and then translating it by vector 0,480 (my screen height=480), but that didn't work too well. Could someone share his/her experience regarding this problem ? I just want to be able to specify coordinates where left,top is 0,0, and y coordinates grow towards bottom, not up, as the default is (for GUI application).
Thank you for your help,

Martin

MichaelNewman
03-03-2003, 03:16 PM
The idea you came up with seems a good one. Perhaps specifying a view frustrum inveretd along the y-axis would do the trick. For instace, you could try glOrtho(-5, 5, 5, -5, -5, 5).

Any particular reason why you want to do this?

Martin_unique
03-04-2003, 02:17 PM
Hello,
Thank you for your reply. I wanted to change the coordinate context because I want to write a 2D app and I wanted to create visual components (like those in Java), where you specify the top left corner as origin and width,height of the component. I thought it would be easier to modify the view matrix instead of keeping the default opengl coordinates and thinking 'ok, I want to draw a rectangle at 10,10, so I really have to draw a rectangle at 10,screenHeight-10'.
Thank you for your help,

Martin

Martin_unique
03-04-2003, 02:25 PM
I forgot to ask - I'm using bitmapped fonts where coordinates are specified by rasterPos2f(). Would those transformations affect the font position too ? I think there might be a problem with inverting bitmapped font - they are always positioned the same, if I'm not mistaken.