PDA

View Full Version : How to determine actual screen coordinates for vertex?



vprabhakar
10-17-2000, 07:43 AM
I am implementing a tooltip feature in my Windows-based OpenGL application. Basically, I want to display come context information when the mouse is moved over one of my OpenGL objects.

My problem is: my OpenGL objects are drawn using calls to vertex3Df, where the coordinates are in world (x,y,z) coordinates. In order to show the tooltip, I need to know what those coordinates map to on the screen.

Is there a conversion function I can call, which, given a vertex3D and whatever tranformation matrices are currently in use, will give me the on-screen x-y location to which that point is mapped?

Thanks,

Vinay Prabhakar
vprabhakar@flashpt.com

Bob
10-17-2000, 07:52 AM
Yepp, have a look at gluProject. You pass the point you want to project, the modelview- and the projection matrix, the viewport size, and it return the screen coordinate for you.

rangers99
03-03-2002, 09:30 PM
Ive looked at glUnproject.

Does it return pixel co-ordinates ie. integers? If so why are the winx, winy parameters returned floating point values?


int gluProject(
GLdouble objx,
GLdouble objy,
GLdouble objz,
const GLdouble modelMatrix[16],
const GLdouble projMatrix[16],
const GLint viewport[4],
GLdouble *winx,
GLdouble *winy,
GLdouble *winz
);

rangers99
03-03-2002, 09:43 PM
Relating to my previous post I am wanting to find screen pixel co-ordinates.

I am rendering my opengl scene into a 640 * 480 window. I am looping through each pixel and trying to get 3D co-ords using gluUnproject.

For some other pixels I am doing the opposite. ie I want the pixel co-ord from gluProject.

Are "windows co-ords" as described in the documenation for these 2 functions different from pixel co-ordinates? If so does anyone have a function that will translate windows co-ords to pixel co-ords (and vice versa)?