Can I use same context for F buffer and Pbuffer?

Hello. I am using pbuffer for dynamic texturing. I want the
glstate of the frame buffer and pbuffer to be same. But when I use same
hglrc, the wglMakeCurrent fails. Is there any way that I can use same
context for the frame buffer and pbuffer. Or any way I can make the
glstate of the frame buffer and pbuffer same?
Thank you very much. I am eager for your reply.

wglMakeCurrent should only fail if the frame buffer and the P-Buffer use differenct pixelformats. See if you can use the same pixel format.

Otherwise you could try using the wglMakeContextCurrentARB entrypoint provided by the WGL_ARB_make_current_read extension (just make the draw HDC and read HDC the same). However, using a GLRC on a DC with a different pixel format than the DC that the GLRC is created with is not well defined. It may not work in some cases.

Originally posted by DanO:
[b]wglMakeCurrent should only fail if the frame buffer and the P-Buffer use differenct pixelformats. See if you can use the same pixel format.

Otherwise you could try using the wglMakeContextCurrentARB entrypoint provided by the WGL_ARB_make_current_read extension (just make the draw HDC and read HDC the same). However, using a GLRC on a DC with a different pixel format than the DC that the GLRC is created with is not well defined. It may not work in some cases.[/b]

Thank you for your reply. But my oglinfo.exe doesn’t display the WGL_ARB_make_current_read extension.
My driver is 29.42, I use Gefore 3 card.
How can I get that extension?
Thanks a lot.

Originally posted by hsun:
Thank you for your reply. But my oglinfo.exe doesn’t display the WGL_ARB_make_current_read extension.
My driver is 29.42, I use Gefore 3 card.
How can I get that extension?
Thanks a lot.

Can’t help you there. The extension is supported on ATI Radeon cards but I guess not on the GeForce.

Make sure you’re looking for it in the WGL extension string and not the regular one.

hsun,

You should definitely be able to use the same rendering context for your pbuffer and the frame buffer. Take a look at this file from the NVIDIA SDK:

http://cvs1.nvidia.com/OpenGL/src/shared/pbuffer.cpp

particularily in the PBuffer::Initialize() function. Look in the places where there is an “if (sharedctx)” or “if (sharecontexts)” for the what to do when you want a shared rendering context.

Basically what you need to do to get a shared rendering context is to retrieve the pixel format from the rendering context using GetPixelFormat(hdc), instead of calling wglChoosePixelFormat, then use this pixel format in your wglCreatePBuffer call.

Finally, instead of creating a new OpenGL rendering context with wglCreateContext, just use the existing rendering context from your main window.

[This message has been edited by jra101 (edited 07-12-2002).]