ARB_occlusion_query defines a mechanism whereby an application can query the number of pixels (or, more precisely, samples) drawn by a primitive or group of primitives. The primary purpose of such a query (hereafter referred to as an "occlusion query") is to determine the visibility of an object. Typically, the application will render the major occluders in the scene, then perform an occlusion query for the bounding box of each detail object in the scene. Only if said bounding box is visible, i.e., if at least one sample is drawn, should the corresponding object be drawn.
I have recently hooked up multiple object selection using the selection buffer. Since in OpenGL 3.0 the selection buffer is deprecated, I was looking into how I could perform multiple object selection using OpenGL 3.0. Several people have mentioned occlusion queries as a possible solution. Since OpenTK support for OpenGL 3.0 is not ready, I used the NVidia extension. Has anyone played with this or has any insight?
uint query; GL.NV.GenOcclusionQueries(1, out query); GL.NV.BeginOcclusionQuery(query); Render(); GL.NV.EndOcclusionQuery(); GL.Flush(); int pixelCount; GL.NV.GetOcclusionQuery(query, All.QueryResult, out pixelCount); bool visible = pixelCount > 0; GL.DeleteQueries(1, ref query);
There is stuff being rendered to the screen, but pixel count is always 0. Quadro FX 550 with the latest NVidia Drivers on Windows XP.