View Full Version : When is appropriate to call glReadPixels?

12-12-2003, 06:27 PM
I program in windows with MFC and want to read framebuffer. I initialized the RC with doublebuffer. I could get right buffer data if i called glReadPixels() just after SwapBuffers() in function CView::OnDraw().
But I always failed when i tried reading buffer by clicking menu to call glReadPixels().
Thank you for all kind fellow!

12-12-2003, 10:24 PM
Do you have an active rendering context ?

If you have something like:
wglMakeCurrent( dc, rc);
render opengl stuff
wglMakeCurrent( NULL, NULL);

Then you cannot execute any OpenGL code without make the rendering context active again with wglMakeCurrent().

Check the error code when you call glReadPixels (using glGetError).


[This message has been edited by mikael_aronsson (edited 12-13-2003).]

12-12-2003, 10:44 PM
That's the point. Thanks.