World coordinates to screen coordinates

Dear All,

I want to exact screen coordinate for a given world coordinate. When you click on the viewport using glutMouseFunc you will get the screen coordinate. But I want to write my own code for the generating the screen coordinates for a given world coordinates instead of using glutMouseFunc(). How to do that.

void worldToscreenCoordinate(worldx, worldy,worldy)



Have a look at gluProject.

The window coordinates you will get are with the origin in the bottom left corner, but the mouse coordinates have the origin in the top left corner, so you still have to invert your y coordinate.