PDA

View Full Version : When is appropriate to call glReadPixels?



diligentbee
12-12-2003, 07: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!

mikael_aronsson
12-12-2003, 11: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).

Mikael


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

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