PDA

View Full Version : Sweep Selection in OpenGL



Jorufo
05-22-2008, 03:39 PM
I am trying to perform a sweep selection where upon mouse down I draw a box on the screen (that part is easy and I have done). Do I have to confine my pick matrix to that box to get the hit records I need. It seems like the box I draw does not match up to what is being returned on the hit. The visual box won't even be over any polygon, but the hit record returns a number as thought it had that many hits. Any suggestions on pulling this off USING THE SELECTION BUFFER?

Jorufo
05-23-2008, 09:21 AM
Anybody?

Jorufo
05-23-2008, 01:54 PM
Somebody?

Relic
05-23-2008, 02:14 PM
Do I have to confine my pick matrix to that box to get the hit records I need.

Yes, gluPickMatrix can help there.


It seems like the box I draw does not match up to what is being returned on the hit. The visual box won't even be over any polygon, but the hit record returns a number as thought it had that many hits. Any suggestions on pulling this off USING THE SELECTION BUFFER?

Make sure your coodinate systems match. Windows mouse coordinates have the origin on the upper left, OpenGL coordinates are normally lower left. Means if you have setup a standard 2D projection your OpenGL y_coordinate = windows_height - 1 - mouse_cordinate;

Selection mode doesn't render. If things do not work as expected setup everything as you would do selection but really render that (do not change glRenderMode to GL_SELECT) and look what the graphics would be.
If that doesn't match what you picked, something is wrong in your matrix setup.
If that looks right, try another OpenGL implementation to isolate a possible driver bug. (I think I read here sometimes that ATI doesn't handle selection or feedback right, dunno.)
Under Windows you can explicitly pick a Microsoft GDI Generic OpenGL implementation. Read the PIXELFORMATDESCRIPTOR manual
http://msdn.microsoft.com/en-us/library/ms537569(VS.85).aspx
to find the dwFlags fields which are required (PFD_GENERIC_FORMAT gives you an MS format).
Check with glGetString(GL_RENDERER) which implementation you use.
Now, if that selection works and your other doesn't, you might have found a driver bug. In that case, update your graphics drivers and try again.
If that still doesn't work come back for more ideas, and present some code.

Jorufo
05-24-2008, 11:16 AM
Thank you Relic. I crown you king of OpenGL!