Skip to main content
GameDev.net gamedev.net
🔒 Locked

Using mouse on a 2D Game [C++ Opengl]

Started by lord4n Oct 14, 2006 at 3:00 PM 2 replies 1.5k views
Original Post
lord4n
lord4n
How can i know what the mouse is pointing at in my 2d game? if i get diffrent resolution evry run. lets say i got a ball on my 2d opengl game the ball location is: x=2 y=3 z=1 how can i know when the mouse is pointing at the ball ?
True knowledge exists in knowing that you know nothing.
anonuser
anonuser
Okay OpenGL isn't really responsible for this. OpenGL should just be drawing a graphical representation of the internal state of your game.

With that said if you use the standard mouse and don't turn in off you can translate the coordinates from world to local coordinates and then perform intersection test.

Google will show you the way to do this. If you're using windows there are specific messages for obtaining the coordinates of the mouse.
zedzeek
zedzeek
goto www.opengl.org + look at the faq or wiki
u will need to unproject the mouse window coordinates this will tell u its worldspace position

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.