glGetQueryObjectiv()

I am trying to use glGetQueryObjectiv( ) in a MacOS project and it fails, throwing and INVALID ENUM error for both GL_QUERY_RESULT and for GL_QUERY_RESULT_AVAILABLE as the argument, i.e.



if(doPick)

{

glEnable(GL_SCISSOR_TEST);

[self setIsPicked: NO];

glGenQueries(1 , &queryId );

glBeginQuery(GL_SAMPLES_PASSED, queryId);

}

modelMatrix = GLKMatrix4Multiply( modelMatrix , viewRotation );

glUniformMatrix4fv(p_matrix_loc, 1, GL_FALSE, projectionMatrix.m);

glUniformMatrix4fv(m_matrix_loc, 1, GL_FALSE, modelMatrix.m);

glBindVertexArray(vao[0]);

glDrawArrays(GL_TRIANGLES, 0, 8 * 3);

if(doPick)

{

glEndQuery( queryId );

queryReady = 0;

glGetQueryObjectiv(queryId, GL_QUERY_RESULT_AVAILABLE, &queryReady);

if( queryReady

{

hits = 0;

glGetQueryObjectuiv(queryId, GL_QUERY_RESULT, &hits);

}

if( hits > 0)

[self setIsPicked: YES];

else

[self setIsPicked: NO];

glDeleteQueries( 1 , &queryId );

glDisable(GL_SCISSOR_TEST);

}


Would anybody know what's going wrong and how I could get this to work. Those enums should be valid.

Accepted Reply

I found it. The line:


glEndQuery(queryId);


should read:


glEndQuery(GL_SAMPLES_PASSED);

Replies

I found it. The line:


glEndQuery(queryId);


should read:


glEndQuery(GL_SAMPLES_PASSED);