Selecting object in 3D in editor

Hi,

I know that there is a lot of posts about that but I think my case is specific.

So I have a 3D editor. I do not use any textures or any advanced stuff. I draw only primitives - lines and rectangles, which locations are kept in memory.
My scene looks like a set of surfaces (big 2D rectangles) with a lot of small circles, which look like holes - they are also 2D shapes located on that big surface.

How can I get to know which object has been clicked (selected) with mouse? I have read about “casting a ray”, gluUnproject etc., but I do not know which method should I use, because I have a lot of those rectangles - from 1000 to 100 000 in whole scene. I want to know which small rectangle (hole) has been selected or which big rectangle has been selected (when user clicks between holes, but inside big rectangle).
It’s an editor, so I’m looking for some simple algorithm rather than fast one (but of course it cannot take too much time - application should work smoothly).

Any sugestions are welcome
Thanks in advance.

You could try using the selection buffer or color buffer readback. I have an example that shows both in an MFC based project if you’d like it. The color readback shows alpha testing too.

Message me an email address if you want the code. Visual Studio 6 and .NET I think (via auto convert).