PDA

View Full Version : translation problem



anglahel
06-14-2001, 09:21 PM
I would like to know how to translate logical to screen coordinates.I am aware of the gluProject/gluUnProject ,but i don't need tehm.What i need is to find a way to estimate how many pixels correspond to a logical unit of length.Any help would be appreciated.

hoshi55
06-15-2001, 04:22 AM
if you are doing stuff on the viewport plane, itīs easy:

one pixel width = viewport_with / screen_x_resolution
oe pixel height = viewport height / screen_y_resolution

so, if you want to draw a dot directly in fron of the camera (basically in 2D) at coordinates (300,200), with a frustum starting at 1.5, do

glBegin(GL_POINTS);
glVertex3f(300*pixwidth-viewport_width/2, 200*pixheight-viewport_height/2, -1.50001);
glEnd();

note that y-coords are upside-down.
the -1.500001 is necessary becaus if you chose -1.5, some gfx drivers assume the point is actually behind your frustum