PDA

View Full Version : Can I use same context for F buffer and Pbuffer?



hsun
07-11-2002, 06:15 AM
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.

DanO
07-11-2002, 07:37 AM
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.

hsun
07-11-2002, 08:13 AM
Originally posted by DanO:
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.

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.

DanO
07-11-2002, 10:35 AM
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.

harsman
07-11-2002, 10:40 AM
Make sure you're looking for it in the WGL extension string and not the regular one.

jra101
07-12-2002, 07:38 AM
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).]