Selection speed issue

I am using GL_SELECT to draw simple quads to assist me in clipping my scene.
In the first quad drawn ONLY, and ONLY for the first time the scene is rendered, the first call to glVertex3f takes around 300ms, whereas every subsequent call takes around 30us (10,000 times less). If the first thing I do is to actually render something (GL_RENDER) instead pseudo-drawing it with GL_SELECT, I don’t get the delay (but I guess I would, the first time I use select mode).

Can anyone explain this behaviour?

(I’m running an NVIDIA Quadro4 580 XGL on 2.8 GHz P4)

Remember, selection runs in software mode. nVidia’s drivers probably want to make sure you’re serious about using selection, so they differ allocations until you actually draw something in selection mode. So, part of that 300ms time is likely memory allocations and whatever setup they need for their software rasterizer.

Use occlusion queries instead.

Originally posted by Csiki:
Use occlusion queries instead.

Thanks for the suggestion. Seems to me that occlusion queries only work in version 1.5 and on NVIDIA cards - is that right? I’m working on Windows XP, which reports version 1.2, and I can’t afford to be hardware specific. Also, assming Korval is right, is there any reason to expect occlusion queries to be more efficient or incur a lower overhead?

Originally posted by Korval:
Remember, selection runs in software mode. nVidia’s drivers probably want to make sure you’re serious about using selection, so they differ allocations until you actually draw something in selection mode. So, part of that 300ms time is likely memory allocations and whatever setup they need for their software rasterizer.

Thanks. That makes sense, although 300ms is forever! I think I need an alternative approach (which I’m discussing on the maths and algorithm forum).

Originally posted by pixelPhile:
Also, assming Korval is right, is there any reason to expect occlusion queries to be more efficient or incur a lower overhead?

Korval is right, and yes, occlusion queries are more efficient.

Good, but I’d be interested to know the reason they are more efficient (e.g., are they done in hardware?)

yes, they are in HW… and occlusion queries are implemented on more cards, just check for the extension ( i know that ATI implements them, even in lower versions of openGL than 1.5)

Thanks very much.