Here is what i do ( as per the specs )
DRAW(){//Z-fill pass for Occlusionfor(int X=0;X<32;X++)for(int Z=0;Z<32;Z++){if(cube[x][z]->infrustum){cube[x][z]->drawTerrain();}}//Occlusion query passglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);glDepthMask(GL_FALSE);for(int X=0;X<32;X++)for(int Z=0;Z<32;Z++){if(cube[x][z]->infrustum){glBeginQueryARB( GL_SAMPLES_PASSED_ARB, cube[x][z]->OCQuery);cube[x][z]->drawTerrain();glEndQueryARB( GL_SAMPLES_PASSED_ARB ); glGetQueryObjectuivARB( cube[x][z]->OCQuery, GL_QUERY_RESULT_ARB, &cube[x][z]->OCcount);}}glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);glDepthMask(GL_TRUE);//Final pass, shaders lightning and so on......for(int X=0;X<32;X++)for(int Z=0;Z<32;Z++){if(cube[X][Z]->OCcount>0)cube[X][Z]->drawTerrain()}}
Now, the thing is that
glGetQueryObjectuivARB
is killing my framerate from ~100FPS to 45, when removed i get ~120FPS.
I can run Occlusion step1, Occlusion step2, Final render - without glGetQueryObjectuivARB and still i have ~120FPS, but when i use
glGetQueryObjectuivARB on each cube my framerate dies..
Why does that happen?
Where is the 'trick' to utilise the power of occlusion culling, i seem to fall into a black hole with this, why use that if it becomes a pain when used..
Just to clarify - terrain is rendered with VBO and has a single call per cell (cube).