Sync & queriesGL 1.5
glGenQueries
Reserves names for query objects, which ask the GPU to measure something (time, visible samples).
Part of the family glGen*
Signature
void glGenQueries(GLsizei n, GLuint *ids);
How it works
A query is a question you ask the GPU while it works: how long did this take, did any pixel of this box survive the depth test. The answer arrives later, usually a frame or two, because the GPU runs behind the CPU. So you keep a small ring of queries (3 or 4) and read the oldest one each frame.
Parameters
nGLsizei
How many.
idsGLuint *
Array receiving the names.
Tips & pitfalls
The DSA form glCreateQueries(target, n, ids) creates the objects at once and fixes their target.
Free them with glDeleteQueries.
Example
example.cpp
1const int N = 4;
2GLuint q[N];
3glGenQueries(N, q);