PBuffers and GL_ARB_occlusion_query

I have a problem about running occlusion queries when a PBuffer render context is enabled. I could not make occlusion query give proper result, i mean the query result returns 0. (using ARB_occlusion_query extension and PBuffers.) is there anybody who used these two and get proper results?
I run the program on GeForceFX 5200, driver 61.77.


Not sure if this helps, but note that occlusion queries are not shared among contexts because they are small. You need to generate them in the context you use them in.
Other than that make sure that you have allocated a pbuffer with a depth buffer and correctly wait until the results are available like in the examples of the ARB_occlusion_query spec.
Here’s what happens if you don’t:

But I think for the ARB version of this extension a busy loop til the query result is available should not be necessary any more, shouldn’t it? I think the call for the query result will block until the result is available?

I don’t think this changed, because it’s still the same hardware running it and the spec has this example:

    do {
        } while (!available);

thanks for the answers.
I had already defined the query in the current PBuffer render context and waited for the occlusion result as it is mentioned in the extension specs. but it did not work. in my first program with GL_ARB_occlusion_query, there was a strange error that i realized. the code was:


ActivateFragmentShader(); // a Cg program

//write the code for occlusion query

// exacly same as the example given in the specs


// look at the sample_count returned by the query
// and do what you want accordingly



The Fragment Shader mentioned above (written with Cg fp30) only sets the depth and color values. This simple occlusion query program had not worked. when i didn’t use Fragment shader it worked fine… it was strange that only after i added to the begining of the display rutine these lines (below), it started working. ( a dummy begin and end query calls)


// a dummy BeginQuery and EndQuery…
glBeginQueryARB(GL_SAMPLES_PASSED_ARB, query);
glClearColor (1.0, 0.0, 0.0, 0.0);

// rest is the same as above
ActivateFragmentShader(); // a Cg program
… // same as above


that is why i was not sure if occlusion queries run properly inside the pbuffers using Fragment shaders. I still could not fix the problem but I will post a message if I can make it run properly…


@Relic: But this is only an example about not wasting time by waiting for the not yet available query result. IMH, this has nothing to do with the need for an explicit app level busy loop…

hi.the occlusion query in a PBuffer context finally worked.what i did wrong was trying to render a polygon directly to PBuffer which is defined to be a float buffer. it is said in the NV_float_buffer extension that fragment programs are aloowed to read and write from floating point PBuffers. problem is eliminated with using a generic fragment program to render polygons. When the data is not written to the buffer occlusion seemed not working to me.
interesting thing still is the need to call dummy Begin and End queries at the begining of the rendering part… occlusion queries seemed not working without these dummy calls. any idea about this?