Thank you NitroGL.
I’m using NV card so I can’t use wglMakeContextCurrentARB, but I failed with several solutions including wglShareLists, ARB_render_texture and NV_render_texture_rectangle.
The weirdest thing I can’t understand is: even the most basic glReadPixels does not work as I expected with P-Buffer:
//
wglMakeCurrent(pbuffer.hDC, pbuffer.hRC);
glDrawPixels(width, height, GL_RGB, GL_UNSIGNED_SHORT, pbuf);
memset(pbuf, 0, bufsize);
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_SHORT, pbuf);
wglMakeCurrent(screen.hDC, screen.hRC);
…
// glReadPixels can retrieve the content of
// P-Buffer successfully if the content is
// rendered using glDrawPixels
but,
//
wglMakeCurrent(pbuffer.hDC, pbuffer.hRC);
…
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
…
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
…
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, L_UNSIGNED_SHORT, pbuf);
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
…
glEnd();
glDisable(GL_TEXTURE_2D);
memset(pbuf, 0, bufsize);
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_SHORT, pbuf);
wglMakeCurrent(screen.hDC, screen.hRC);
…
// Simply replace glDrawPixels with
// glTexImage2D will make glReadPixels fail
// to retrieve the content of P-Buffer.
// !!!
Any comments?