View Full Version : Selecting objects.

07-18-2000, 04:38 AM
Lets say i have 100 objects on the scene (for example shperes) and I want to be able to click on a object and have it highlight it. Should i use the selection buffer or is there an easier way of doing this?


07-18-2000, 09:56 AM
I would go for the selection buffer, because it's precise and it was meant for this task.
You don't have to hassle with glReadPixels from the depth buffer, gluUnproject, and a for loop with some collision detection routine (well, for spheres that might be easy and fast enough).

There is another rather simple and straightforward method:
Code the IDs of the objects in colors, disable all lighting and other effects like blending, stipple etc. and draw the scene in the back buffer, get the color of the clicked pixel and decode the ID from the color value.
This will only work properly if your ID encoding takes the color depth into account, i.e. better avoid high color resolutions and dithering. http://www.opengl.org/discussion_boards/ubb/smile.gif

07-18-2000, 02:38 PM
Rellic: can you show some code.. i mean, to use glgetpixel...
i don't know how i can do that man...

i want the same as Whittick. Select some object using the mouse.

and if isn't ask too much, how can i use the mouse to make some rotation, like the most of "first person" games -> HL, Q3 and stuff.

i ll really appreciate if you or someone help me !!!!

here my mail: gfumec@hotmail.com

thanx !!!!

good night !!!

07-19-2000, 01:24 AM
Look in the "About OpenGL"->FAQs->Technical on this site and you'll find some useful hints on your problem in paragraph 4.070 and 14.040.
Start here: http://www.opengl.org/About/FAQ/Technical.html

And look for the precise parameters of glReadPixels in http://msdn.microsoft.com/library/default.asp?URL=/library/psdk/opengl/legalgl_62pa.htm
You'll need the GL_DEPTH_COMPONENT.

[This message has been edited by Relic (edited 07-19-2000).]