When is appropriate to call glReadPixels?

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!

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).]

That’s the point. Thanks.