View Full Version : Problem with Region selection!

12-12-2006, 09:14 PM
I want to implement a region selection using a back buffer selection method. I know opengl has its own selection mechanism but it's too slow for me.

Let say we have 2 circle that overlap with each other at certain region. To implement the back buffer selection, we just simply assign a different color ID for each circle and use glReadPixels to get the pixel for the current mouse position. But the problem is if our region selection is lie within the overlapping region. And only one color ID will be returned in this case. But what I want is all the entities that lie within the region selection to be selected. So can someone help me to solve this problem? Thanks.

12-12-2006, 11:30 PM
You can use occlusion query:
1.setup scissor test to a rectangle covering only the pixel you want to test
2.for all objects
-begin query <n>
-draw object <n>
-end query <n>
3.do something else to give GPU some time to finish the job (since we draw to just 1 pixel that should be fast)
4.read queries, and those that returned something different than 0 are the objects you have selected

12-14-2006, 09:35 PM
Thanks buddy.