0

I'm trying to create an occlusion query using openGL 3.3, using GLFW, GLEW

load function:

uint32_t glQueryID;
glGenQueries(1, &glQueryID);
if (glIsQuery(glQueryID)) //just for testing its always false !
{
 ... it must be always true !?!
}

draw function:

glBeginQuery(GL_ANY_SAMPLES_PASSED, glQueryID);
glGetError();// 1282 invalid operation

However all my other glCalls worked correctly without any error

Running on Mac OS X, intel HD 4000

mofed8461
  • 26
  • 8

2 Answers2

2

From the documentation of glIsQuery:

glIsQuery returns GL_TRUE if id is currently the name of a query object. If id is zero, or is a non-zero value that is not currently the name of a query object, or if an error occurs, glIsQuery returns GL_FALSE.

A name returned by glGenQueries, but not yet associated with a query object by calling glBeginQuery, is not the name of a query object.

Since you call glIsQuery before assinging a query object to it (for example by calling glBeginQuery), the return value has to be GL_FALSE.

Community
  • 1
  • 1
BDL
  • 21,052
  • 22
  • 49
  • 55
  • Thanks very much, I would mention that the problem was solved by initialize the query with empty begin and end .. i don't know what was the cause of invalid operation error `glGenQueries(1, &glQueryID); glBeginQuery(GL_SAMPLES_PASSED, glQueryID); glEndQuery(GL_SAMPLES_PASSED);` – mofed8461 Mar 25 '17 at 18:30
0

The problem was solved by initializing query followed by empty begin/end Query

glGenQueries(1, &glQueryID);
glBeginQuery(GL_SAMPLES_PASSED, glQueryID);
glEndQuery(GL_SAMPLES_PASSED);

this will fix error 1282 (invalid operation) when drawing later

mofed8461
  • 26
  • 8