PDA

View Full Version : pixel to World



01-26-2004, 05:57 PM
can someone help me out with a problem i can't seem to solve ? given a viewing projection and a modelview matrix is there some way to obtain a pixel to world ratio ? what i need this is to draw 3D objects which are always constant pixel in size even though the orientation is variable. so say i wanted to draw a line that was always 20 pixels in length and initially in the X direction then i would want to do something like :

glBegin(GL_LINES);
glVertex3d(0.,0.,0.);
glVertex3d(20*worldToPixel(),0.,0.);
glEnd();

thanks

Tzupy
01-26-2004, 11:35 PM
Hi,
You can use gluUnproject to get the world coordinates of two window corners. Just divide the window size (in world) by the window size (in pixels, if != 0).