Screen capture with OpenGL


Is there any way to make a screen capture using OpenGL on Windows Vista (the whole screen) ?

I know it is possible to do it on MacOSX using glReadPixels but I can’t find a way to do it on Windows.

I tried to do this get the screen DC using

Then I created a pixel format and create a context with
like they do in VLC for taking a screenshot on MacOSX but when I try to use wglMakeCurrent before calling glReadPixels it does not work. I also tried to make a copy using wglCopyContext but it still does’t work.


I don’t see the relation between Device Context and the framebuffer…
After creating DC and RC and initializing Opengl, you should be able to draw something and read framebuffer data calling glReadpixels. maybe, you should paste more code.

Mac OS X uses OpenGL for drawing to the screen so you can use glReadPixels to get the whole screen since there is an OpenGL context for it.
Windows Vista uses DirectX so I think you’re out of luck here.

if i understand correct you want to capture whole desktop with OpenGL? never seen that before. You can get a HDC handle from desktop by calling GetDC(NULL) if i recall correct and then using BitBlt to move/copy it to another DC. so guess there is a way but i never seen anything like that.

Use the print screen key !

Or use the win32 API:

HBITMAP CopyScreenToBitmap(LPRECT lpRect)