Selecting objects.

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?


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.

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:

thanx !!!

good night !!!

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:

And look for the precise parameters of glReadPixels in
You’ll need the GL_DEPTH_COMPONENT.

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