Has anyone else written code that copies an image from the “visual”/frame buffer to a pbuffer. My application needs to isolate parts of the out-the-window scene, perform image processing, and then paste the results over the top of the original scene image using alpha blending.
The code is as follows…
switch_context(pbuf->dc, GL_FRONT, fbuf->dc, GL_BACK, pbuf->rc); //WGL Wrapper
glPixelZoom(pbuf->dim/fbuf->width, pbuf->dim/fbuf->height);
glWindowPos2i(0,pbuf->dim);
glCopyPixels(0,0, fbuf->width, fbuf->height, GL_COLOR);
It works fine, but there are some causes for concern…
- The glWindowPos2i causes a gl-error (invalid op) when I use it to set the pbuffer’s current raster position. I found the 0,pbuf-dim values through experimentation (I expect 0,0 to work), but these values do indeed allow the copy to work.
- I read the extension papers very carefully, but had to make some calculated guesses, so I’m not 100% sure these operations will work on other cards. (My development card is a ATI X800).
Did I get Lucky? Is there a better way? Thanks in advance …