Jump to content
  • Advertisement
Sign in to follow this  
lord4n

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

This topic is 4238 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 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 ?

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!