I am trying to write a sample opengl application for occlusion query to identify visible triangles. But occlusion query always returns zero count for pixel sampling.
I follow below steps to do so:
Setup opengl\glut
Call lookat from a point (from where complete model is visible)
- Enable depth test, depth mask, enable face culling ( and few other options).
- Render complete model.
- Disable depth mask
- Start new occlusion query
- Render a triangle \ face
- End query and wait until result is available.
- Once result is available then get count.
- Repeat step 6 to 9 for all triangles \ faces.
For given model I compute bbox and enlarge it by some factor (say 1.5) so as complete model is visible. From each corner of bbox, I call step 2-10 and with eye point as corner.
Here issue is for each query result of step #9 (output of occlusion ) query is 0, i.e. it is stating number of visible pixel are zero.
I have attached sample application here (ObjRender Sample) which loads OBJ file and perform above step 1-10. To reproduce it just open VS project, build and run it. It has sample data with it.