Advertisement

OpenGL and MFC flickering

Started by August 29, 2000 11:39 PM
3 comments, last by Kinfira 24 years, 2 months ago
My problem is that I am getting serious flickering using OpenGL in an MFC window. My MFC program uses the standard document/view architecture and I use OpenGL to draw all of the objects on the screen (inside the OnPaint message handler). Whenever I update the screen, as in move an object with the mouse or zoom in or out, whatever, anything drawn on the screen flickers. What I have noticed is that it appears as if there is a background window underneath the OpenGL window. By that I mean that if I color the regular MFC window white and clear the OpenGL buffer to black, I can see the white window then the black buffer overlaid on top each time I update the screen. It sort of redraws the white one then the black one each and every time. I wrote another MFC and OpenGL program a while back with no flickering but the difference is that the older program opened a new window which used OpenGL. I get no flickering with that window. Has anyone else had this problem? If so how do I go about solving it? I am writing a series of MFC based tools for my engine just in case that helps any. Thanks for any reply, Kinfira.
Regards, KinfiraLead ProgrammerKinfiraSoftMakers of Swordplay, a 3D fighting game engine.Check out our home on the web:http://www.kinfirasoft.com
I had a similar problem with an MFC app i created a few months back but i wasnt using openGL so i cant help much there. BTW its a good idea to use the Views call to OnDraw instead of OnPaint, i noticed my app cleared up for the most part after doing that. whenever you draw on the screen or mess it up otherwise just call Invalidate([optional rect]) which calls OnDraw. Hope this helps at all.
Advertisement
I''d guess the problem is WM_ERASEBKGND. Try creating a handler for it with a body like { return 1; }. Also make sure you call ::ValidateRect(your_window_handle, NULL) from OnPaint().

Hope this helps.
Hey thanks fo the replies!!!

vladg: I took your suggestion (OnEraseBkgnd) and it worked. Thanks for the help.



L8tr, Kinfira.
Regards, KinfiraLead ProgrammerKinfiraSoftMakers of Swordplay, a 3D fighting game engine.Check out our home on the web:http://www.kinfirasoft.com
i know u have fixed the problem but a MFC window according to the MS documentation only creates a single buffered window

This topic is closed to new replies.

Advertisement