View Full Version : translation problem
06-14-2001, 10: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.
06-15-2001, 05: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
glVertex3f(300*pixwidth-viewport_width/2, 200*pixheight-viewport_height/2, -1.50001);
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
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.