Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

NicolasEC

Selection by the mouse

This topic is 5212 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

Hi, I am drawing a face made of triangles, and i would like to be able to select (by the mouse) any one of these triangles. I am trying to achieve this goal by this way : when im drawing a triangle, i use at first : - glRenderMode(GL_FEEDBACK) in order to get all the coordinates in a buffer array (the coordinates in the frame). - then, i use glRenderMode(GL_RENDER) to draw the triangles in the frame And when a mouse event occurs, i test if the coordinates of the mouse are corresponding to one or more of the triangles i''ve stocked in the buffer array. Does anyone know another way ? This one isnt a good one because i have to compute, for all of the 9000triangles, a fonction called : boolean isCoordinatesInTriangle, which tests if the coordinates of the mouse is contained in one of the triangles. So, one way would be : when a draw a triangle, i get the pixels that are corresponding to this triangle, and stock in a buffer[800][600] the indices of the triangle. Example : if buffer[10][10]=150, it means that if the coordinates of the mouse are (100,100), we are clicking on the 150th triangle. But i dont know how to do that. Thanks a lot for help, and to have read me until here

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!