diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index 82af6fe650..60e67122a6 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -521,6 +521,20 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message, switch (message) { + case WM_PAINT: + { + PAINTSTRUCT ps; + HDC hdc = BeginPaint(hwnd, &ps); + + // All painting occurs here, between BeginPaint and EndPaint. + + FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1)); + + EndPaint(hwnd, &ps); + break; + } + case WM_ERASEBKGND: + break; case WM_DROPFILES: case WM_SYSCOMMAND: case WM_CHAR: diff --git a/gfx/drivers/gdi_gfx.c b/gfx/drivers/gdi_gfx.c index 373b6a30bc..6ed6baf16e 100644 --- a/gfx/drivers/gdi_gfx.c +++ b/gfx/drivers/gdi_gfx.c @@ -220,6 +220,7 @@ static bool gdi_gfx_frame(void *data, const void *frame, unsigned height = 0; bool draw = true; gdi_t *gdi = (gdi_t*)data; + HWND hwnd = win32_get_window(); if (!frame || !frame_width || !frame_height) return true; @@ -256,12 +257,14 @@ static bool gdi_gfx_frame(void *data, const void *frame, if (draw) { - unsigned win_width, win_height; - HWND hwnd = win32_get_window(); - HDC dc = GetDC(hwnd); + HDC winDC = GetDC(hwnd); + HDC dc = CreateCompatibleDC(winDC); + HBITMAP bmp = CreateCompatibleBitmap(winDC, width, height); BITMAPINFO info; gfx_ctx_mode_t mode; + SelectObject(dc, bmp); + video_context_driver_get_video_size(&mode); ZeroMemory(&info, sizeof(BITMAPINFO)); @@ -310,15 +313,17 @@ static bool gdi_gfx_frame(void *data, const void *frame, */ StretchDIBits(dc, 0, 0, mode.width, mode.height, 0, 0, width, height, frame_to_copy, &info, DIB_RGB_COLORS, SRCCOPY); - ReleaseDC(hwnd, dc); + DeleteObject(bmp); + DeleteDC(dc); + ReleaseDC(hwnd, winDC); } + InvalidateRect(hwnd, NULL, true); + video_context_driver_update_window_title(); video_context_driver_swap_buffers(); - //UpdateWindow(win32_get_window()); - return true; }