From 9689f9e9ad5f17daa9a61998859443be7a41a76f Mon Sep 17 00:00:00 2001 From: Diederick Niehorster Date: Fri, 1 Mar 2013 18:28:55 +0000 Subject: [PATCH] WM_PAINT more conform to docs git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1546 7f0cb862-5218-0410-a997-914c9d46530a --- src/mswin/fg_main_mswin.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/mswin/fg_main_mswin.c b/src/mswin/fg_main_mswin.c index 4bd7039..c9c0ccf 100644 --- a/src/mswin/fg_main_mswin.c +++ b/src/mswin/fg_main_mswin.c @@ -648,14 +648,21 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR case WM_PAINT: { - PAINTSTRUCT ps; - /* Turn on the visibility in case it was turned off somehow */ - window->State.Visible = GL_TRUE; - - InvalidateRect( hWnd, NULL, GL_FALSE ); /* Make sure whole window is repainted. Bit of a hack, but a safe one from what google turns up... */ - BeginPaint( hWnd, &ps ); - fghRedrawWindow( window ); - EndPaint( hWnd, &ps ); + RECT rect; + + if (GetUpdateRect(hWnd,&rect,FALSE)) + { + /* As per docs, upon receiving WM_PAINT, first check if the update region is not empty before you call BeginPaint */ + PAINTSTRUCT ps; + + /* Turn on the visibility in case it was turned off somehow */ + window->State.Visible = GL_TRUE; + + InvalidateRect( hWnd, NULL, GL_FALSE ); + BeginPaint( hWnd, &ps ); + fghRedrawWindow( window ); + EndPaint( hWnd, &ps ); + } } break; -- 1.7.10.4