The question is simple, how can I identify which object has been touch开发者_如何学Pythoned by the user in OpenGL. I've tried the utilizat envento onTouchEvent but this only returns the possição X, Y screen.
A similar question was asked (& answered) in this thread: Detect user's touches over an OpenGL square
Basically there are 2 methods: 1 rendering all objects to a buffer in all different colours and then looking at the colour information at the specified 'pick coordinate' to identify your object. The other (and I think less resource intensive) is retrieving the 'ray' and then doing a hit test with bounding boxes you provide for all your objects currently rendered on the screen.
edit: If you're doing your rendering orthographically/2d then this somewhat simplifies things. You can do a simple hit Test with the point you touched and a rectangle (or circle or polygon perhaps) you provide for the image that you've drawn.
Hope this helps.
精彩评论