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 ???

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);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.