Do games uses the slection buffer?

For example, a game like Age of Empire (or Empire Earth)…Did they program the unit selection code using a ‘selection buffer’ like approach? Why Im asking is, if its wise to use the OGL selection buffer in games, or if there is some other method (faster?). Thx guys!

Selection buffer is not something you should use in games. It’s not that fast on hardware used for gaming. Either simulate the selection buffer in the back buffer, by drawing objects in different colors, read back the color, and determine what colors are “selected”. Of course, you need to do it in the back buffer so it don’t appear on the screen. Or you can cast a ray from the viewpoint, and see if it intersects the object’s bounding box.

Yes color can get you fragment tests also. But picking may be faster for fill limited scenes, and readback can be slow and tricky, depending on whether you want to use a dragbox or a simple small point to pick. Aliasing issues also arise. Picking will pick all objects under the cursor, readback will not unless you do many readbacks. You may see this as an advantage for picking in a depth buffered scene.

So, what is THE right way of doing selection in a strategy like game, or better yet, how do they do it in games like Empire Earth. If someone has experience with this, please reply!!! Thx

There is no correct way, that’s a bad mindset.

I’d wager they do it in software on these games, it’s more portable. You need dragboxes and on the fly highlighting as you drag while you animate meaning that with selection you’d be drawing the pickable objects twice, albeit with simple geometry, simple bounds or lowest LOD. You could either generate a dragbox frustum and software cull the units to it, using a simple bounding sphere for speed. If you use selection you get a more accurate pick which you might want to do instead. Only draw the lowes level of detail, and only draw the pickable objects to the selection buffer.

Image readback would be a pig, don’t do that.