Hi .
Why not have a occlusion_query_test command in the OpenGL, a command that can jump a block of
commands in the list, if the number of samples in a occlusion query is not what we want.
This way we donīt need to use GetQueryObject and stall the pipeline.


Using the ARB_occlusion_query example as base:

GLuint queries[N];
GLuint sampleCount;

glGenQueriesARB(N, queries);


// First rendering pass
glDisable(GL_BLEND);
glDepthFunc(GL_LESS);
glDepthMask(GL_TRUE);
// configure shader 0
for(i=0; i<N; i++)
{
glBeginQueryARB( GL_SAMPLES_PASSED_ARB, queries[i] );

// render object i

glEndQueryARB(GL_SAMPLES_PASSED_ARB);
}

// Second pass only on objects that were visible
glEnable(GL_BLEND);
glBlendFunc(...);
glDepthFunc(GL_EQUAL);
glDepthMask(GL_FALSE);

// configure shader 1
for(i=0; i<N; i++)
{
// Only render if sample count > 0
glBeginQueryTestARB( GL_QUERY_RESULT_ARB, queries[i], GL_GREATER, 0 );

// render object i

glEndQueryTestARB();
}

I hope someone understand what Iīm trying to say, since my English is not good.