Advertisement Jump to content
Sign in to follow this  
Four

OpenGL mouse coordinates to opengl

This topic is 4984 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How may I get the coordinates of mouse to opengl coordinates. I looked at a tutorial on Nehe, it works but the problem is, it only works properly when the viewport is the entire screen. Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
Hi,
Make sure you do this somthing like this:

Mouse_coord_in_ogl_Y= Window_Height-Mouse_Y_position
Mouse_Y_position=this the Coord for the mouse that you get it from HIWORD() (if you use windows.h)

Share this post


Link to post
Share on other sites
Maybe not exactly related, but still.
I wonder how in theory the Mouse-OpenGL coordinate translation works.
Nouse coordinate is a point in 2D space, so that would give me a line in 3D space, right? If I remember correctly, there is a GLU function that does the translation, but what does it give you? The line formula, or a point on the line (and which point, if so)?

Share this post


Link to post
Share on other sites
Thank you!

The mistake I made is when trying to get where point is in opengl coordinates is that, before doing anything from the very begining once I get the coordinates of the mouse I should revert the y coordinates to be (0,0) at lower left corner(height-y).

[quote=Seroja]Maybe not exactly related, but still.
I wonder how in theory the Mouse-OpenGL coordinate translation works.
Nouse coordinate is a point in 2D space, so that would give me a line in 3D space, right? If I remember correctly, there is a GLU function that does the translation, but what does it give you? The line formula, or a point on the line (and which point, if so)?[/quote]

The function is gluUnProject, I don't know how it works too, it would be very interesting to hear. gluUnProject gives a point on the line.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!