Hello I tried to implement occlusiong culling to my engine in opengl using java & lwjgl. Occlusion works but... performance drop is huge I mean from 60-70 fps to 3-6 fps. Here is my question what I'am doing wrong ? Here is my code:
//this code is after frustrum culling if object passed
glColorMask(false, false, false, false);
glDepthMask(false);
glBeginQuery(GL_SAMPLES_PASSED, query_id);
//renderable is cube not normal object
renderable.render();
glEndQuery(GL_SAMPLES_PASSED);
int iSamplesPassed = GL15.glGetQueryObjecti(query_id, GL15.GL_QUERY_RESULT);
if(iSamplesPassed == 0) {
//object is not visible don't render it
renderable.setVisible(false);
}
glColorMask(true, true, true, true);
glDepthMask(true);
query_id is simply:
query_id = glGenQueries(); //it is called only once on start
I look on some examples and I don't see any diffrences in code. Only diffrence is their and my framerate.