0

Hello World !!! I am having problem in my project regarding mouse click within a particulr area on GL surface screen...when I click on that particular area..mouse click generates windows coordinate like (200,349). It's hard to sense the mouse click in that area on GL surface screen....so how can I convert the GL units into windows coordinate. Plz help me.....I know the logics regarding game projects ...but it's complicated to apply those logics in learning new API packages..how they work ...help me ???

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by mike_2000_17
0

The OpenGL window always goes from -1 to 1 on both x and y coordinates. You can just take those windows coordinates in pixels and use some simple formulas to transform the ranges [0, pixel_width] and [0, pixel_height] into [-1,1] and [-1,1], and that's it.

If you want to actually know where those mouse clicks end up on the 3D world, that is not really possible unless you specify the depth. If you add a depth value, then you can simply invert the projection matrix (which you can obtain with glGetFloatv(GL_PROJECTION_MATRIX, &m);

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.