glGetQueryObject.3G - Man Page

return parameters of a query object

C Specification

void glGetQueryObjectiv(GLuint id, GLenum pname, GLint * params);

void glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint * params);

void glGetQueryObjecti64v(GLuint id, GLenum pname, GLint64 * params);

void glGetQueryObjectui64v(GLuint id, GLenum pname, GLuint64 * params);



Specifies the name of a query object.


Specifies the symbolic name of a query object parameter. Accepted values are GL_QUERY_RESULT or GL_QUERY_RESULT_AVAILABLE.


If a buffer is bound to the GL_QUERY_RESULT_BUFFER target, then params is treated as an offset to a location within that buffer's data store to receive the result of the query. If no buffer is bound to GL_QUERY_RESULT_BUFFER, then params is treated as an address in client memory of a variable to receive the resulting data.


glGetQueryObject returns in params a selected parameter of the query object specified by id.

pname names a specific query object parameter. pname can be as follows:


params returns the value of the query object's passed samples counter. The initial value is 0.


If the result of the query is available (that is, a query of GL_QUERY_RESULT_AVAILABLE would return non-zero), then params returns the value of the query object's passed samples counter, otherwise, the data referred to by params is not modified. The initial value is 0.


params returns whether the passed samples counter is immediately available. If a delay would occur waiting for the query result, GL_FALSE is returned. Otherwise, GL_TRUE is returned, which also indicates that the results of all previous queries are available as well.


If an error is generated, no change is made to the contents of params.

glGetQueryObject implicitly flushes the GL pipeline so that any incomplete rendering delimited by the occlusion query completes in finite time.

If multiple queries are issued using the same query object id before calling glGetQueryObject, the results of the most recent query will be returned. In this case, when issuing a new query, the results of the previous query are discarded.

glGetQueryObjecti64v and glGetQueryObjectui64v are available only if the GL version is 3.3 or greater.

GL_QUERY_RESULT_NO_WAIT is accepted for pname only if the GL version is 4.4 or greater.

The GL_QUERY_RESULT_BUFFER target is available only if the GL version is 4.4 or higher. On earlier versions of the GL, params is always an address in client memory.


GL_INVALID_ENUM is generated if pname is not an accepted value.

GL_INVALID_OPERATION is generated if id is not the name of a query object.

GL_INVALID_OPERATION is generated if id is the name of a currently active query object.

GL_INVALID_OPERATION is generated if a buffer is currently bound to the GL_QUERY_RESULT_BUFFER target and the command would cause data to be written beyond the bounds of that buffer's data store.

Version Support

OpenGL Version
Function / Feature Name2.

See Also


glEndQuery, glGetQueryiv(), glIsQuery(), glQueryCounter()

Referenced By

glBeginQuery.3G(3), glBeginQueryIndexed,_glEndQueryIndexed.3G(3), glCreateQueries.3G(3), glDeleteQueries.3G(3), glGet.3G(3), glGetQueryIndexediv.3G(3), glGetQueryiv.3G(3), glQueryCounter.3G(3).