Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Kinfira

OpenGL and MFC flickering

This topic is 6678 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Hey thanks fo the replies!!!

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



L8tr, Kinfira.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!