Selection by the mouse

Started by
-1 comments, last by NicolasEC 20 years ago
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

This topic is closed to new replies.

Advertisement