Error with PBuffer

Hello everybody,

I am developping an application under Windows XP for which I need to create a pbuffer so that I can use glReadPixels correctly. I want to be able to draw a complex scene with textures and lights on this pbuffer but i cannot manage to do so : i get an ‘invalid operation error’ from openGL and i don t know exactly where it comes from. Note that i try to use that with open scene graph, if that can help. Is it related to the complexity of the scene I want to render in the pbuffer?

I would be grateful to anyone who could give me some hints.

Jong

i get an ‘invalid operation error’ from openGL and i don t know exactly where it comes from.

So, try to find it out

How do you create your pbuffer ? (code)

PS: mmh, I am not familiar with OSG, but they seem to have a pbuffer sample at http://openscenegraph.sourceforge.net/documentation/OpenSceneGraph/examples/osgpbuffer/ . If you have not seen it yet, it will probably help you.

You can look at my simple pbuffer test, at http://www.chez.com/dedebuffer but is almost pure opengl+wgl. I don’t know if it mixes well with OSG.

[This message has been edited by ZbuffeR (edited 02-06-2004).]

I want to use Render-To-Texuture in my problem, but it is a multi-pass algorithm. That’t is to say, the result of Render-To-Texture would be used in the next pass as an input texture. I wonder why the texture is set to zero in the next pass rendering with pbuffer. The following absolutely Not work.
for(i=0; i<nPass; i++)
{
glBindTexture(_iTextureTarget, resultTextureID);
wglReleaseTexImageARB(_hPBuffer, WGL_FRONT_LEFT_ARB);
wglMakeCurrent( _hDC, _hGLContext);///PBuffer context

glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(_iTextureTarget, resultTextureID);  

DrawSomeThingWidthTexture_resultTextureID;

glBindTexture(_iTextureTarget, resultTextureID);
wglMakeCurrent( _hPreviousDC, _hPreviousContext);
wglBindTexImageARB(_hPBuffer, WGL_FRONT_LEFT_ARB); 	

}

So in the following program, I introduce an intermediate texture as the texture of Render-To-Texture, then swap it with the input texture. But it still doesn’t work. Can you tell me the reason, or give me any suggestion?

Initially the data from texture resultTextureID is zero.
for(i=0; i<nPass; i++)
{
glBindTexture(_iTextureTarget, intermedTextureID);
wglReleaseTexImageARB(_hPBuffer, WGL_FRONT_LEFT_ARB);
wglMakeCurrent( _hDC, _hGLContext);///PBuffer context

glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(_iTextureTarget, resultTextureID);

///Here I check it, the data from texture resultTextureID is zero,
///even in the next pass

DrawSomeThingWidthTexture_resultTextureID;

glBindTexture(_iTextureTarget, intermedTextureID);
wglMakeCurrent( _hPreviousDC, _hPreviousContext);
wglBindTexImageARB(_hPBuffer, WGL_FRONT_LEFT_ARB);

///Swap the Texture ID
tempID = intermedTextureID;
intermedTextureID = resultTextureID;
resultSetTextureID = tempID;
////Here I find the the data from texture resultTextureID is the rendering result
////But why in the next pass, it returns to zero?
////And I think in the begining of each pass, just the data from intermedTextureID should be zero,WHY?

}

Thank you in advance.

Common reasons for pbuffer failure:

  1. not requesting Pbuffer support in the original render context. This requires the wgl pixel format extension, which requires another, initial, context just to get the extension functions (you can close that context when done)

  2. not creating a pbuffer with the exact same pixel format that your original context is for (including double buffering, etc) – alternately, not creating a correct second context for the pbuffer

  3. not using wglShareLists between the contexts when you use a pbuffer in a separate context

  4. not using the right DC/RC combination when making contexts current

  5. assuming state that does not transfer over between contexts, such as enables, array pointers, or fences (to name a few)