I’d like to share a single OpenGL rendering context between two different drawing surface (a window and a pbuffer). Is there a way to do so under Windows?
I’ve tried with the following code, but after a wglMakeCurrent(hDC_pbuffer, hRC_window), I got a ERROR_INVALID_PIXEL_FORMAT from GetLastError.
// Pixel format for the window surface
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
24,
0, 0, 0, 0, 0, 0,
8,
0,
0,
0, 0, 0, 0,
16,
8,
0,
PFD_MAIN_PLANE,
0,
0, 0, 0
};
// Pixel format for the pbuffer surface
{
WGL_DRAW_TO_PBUFFER_ARB, 1,
WGL_COLOR_BITS_ARB, colorBits,
WGL_ALPHA_BITS_ARB, colorBits == 32 ? 8 : 0,
WGL_DEPTH_BITS_ARB, depthBits,
WGL_STENCIL_BITS_ARB, stencilBits
};
Any kind of help (and code snippets) will be really appreciated. Thanks in advance!
Matteo.