Occlusion Query -> GL Error: Invalid Ops.

Hi,

when using ARB_occlusion_query or NV_occlusion_query i get a GL Error (Invalid Operands) at the line where the queries’ results are retrieved. I used the code example in the ARB/NV extension spec as a guideline but i cannot find anything wrong in the code.

Any idea/hints?

Thank you very much in advance.

regards,
Stephan

if( !GLEW_NV_occlusion_query ) return;
glDepthFunc( GL_LEQUAL );

glDisable( GL_TEXTURE_2D );

Point3D vPt;
glPointSize( 64.0f );
int i=0;
glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
glDepthMask(GL_FALSE);
for( float fAng = 0.0f; fAng < PI2.0f, i < 8; fAng += 0.25PI, i++ )
{
vPt = vRight_ * sin(fAng) * fSize_ + vUp_ * cos(fAng) *fSize_ + vCurrentSunPos_;
glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); glDepthMask(GL_FALSE);
braucht!.
assert( 1+i < 9 );
glBeginOcclusionQueryNV( uiOcclusionQuery_[1+i] );
glBegin(GL_POINTS);
glVertex3f( vPt.x, vPt.y, vPt.z );
glEnd();
glEndOcclusionQueryNV();
}

glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
glDepthMask(GL_TRUE);

for(int i=1; i < 9; i++ )
{
// SKip the [0] result for now!
glGetOcclusionQueryuivNV( uiOcclusionQuery_[i], GL_PIXEL_COUNT_NV,&uiVisibility_[i]);

}

[This message has been edited by stephanh (edited 01-12-2004).]

The spec contains the conditions which result in an invalid operation. Make sure you didn’t hit one of them.

Here’s the list:

  • What happens if glBeginOcclusionQueryNV is called when an
    occlusion query is already outstanding for a different object?

    RESOLVED: This is a GL_INVALID_OPERATION error.
    

If BeginOcclusionQueryNV is called with an unused id, that id is
marked as used and associated with a new occlusion query object. If
it is called while another occlusion query is active, an
INVALID_OPERATION error is generated. If EndOcclusionQueryNV is
called while no occlusion query is active, an INVALID_OPERATION error
is generated. Calling either GenOCclusionQueriesNV or
DeleteOcclusionQueriesNV while an occlusion query is active causes an
INVALID_OPERATION error to be generated.

If the occlusion query object named by id is currently active, then
an INVALID_OPERATION error is generated.

  • Means, make sure your glGenQueries has succeeded. (Where is it?)
  • You might want to issue a glFlush after the final glEndOcclusionQuery to start processing immediately.
  • The correct way is to loop on glGetOcclusionQueryuivNV(…, GL_PIXEL_COUNT_AVAILABLE_NV, …); before querying the actual GL_PIXEL_COUNT_NV.

Other tips.
Do not call glDisable inside the for loop where you issue the occlusions, once outside is enough.
Do not use a small letter ‘L’ as variable. It’s too easy to read for ‘1’ (digit one).
What is ‘l’ in your code?

Your first for-loop is called 7 times. The last can be called eight times, if l == 0.

[This message has been edited by Relic (edited 01-12-2004).]

Thank you very much Relic!

Originally posted by Relic:

  • Means, make sure your glGenQueries has succeeded. (Where is it?)
  • You might want to issue a glFlush after the final glEndOcclusionQuery to start processing immediately.
  • The correct way is to loop on glGetOcclusionQueryuivNV(…, GL_PIXEL_COUNT_AVAILABLE_NV, …); before querying the actual GL_PIXEL_COUNT_NV.

I wasn’t waiting for the query to finish. that caused the errors.

Other tips.
Do not call glDisable inside the for loop where you issue the occlusions, once outside

glColorMask inside the four loop was from a comment. isn’t there in the real code.

regards,
Stephan

Glad to help. Nice math on your web page!