GDI: xmb draws for a few seconds and then freezes

This commit is contained in:
Brad Parker 2017-01-08 15:27:51 -05:00
parent 90ef57948c
commit 8eba18a54f
2 changed files with 25 additions and 6 deletions

View File

@ -521,6 +521,20 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message,
switch (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_DROPFILES:
case WM_SYSCOMMAND: case WM_SYSCOMMAND:
case WM_CHAR: case WM_CHAR:

View File

@ -220,6 +220,7 @@ static bool gdi_gfx_frame(void *data, const void *frame,
unsigned height = 0; unsigned height = 0;
bool draw = true; bool draw = true;
gdi_t *gdi = (gdi_t*)data; gdi_t *gdi = (gdi_t*)data;
HWND hwnd = win32_get_window();
if (!frame || !frame_width || !frame_height) if (!frame || !frame_width || !frame_height)
return true; return true;
@ -256,12 +257,14 @@ static bool gdi_gfx_frame(void *data, const void *frame,
if (draw) if (draw)
{ {
unsigned win_width, win_height; HDC winDC = GetDC(hwnd);
HWND hwnd = win32_get_window(); HDC dc = CreateCompatibleDC(winDC);
HDC dc = GetDC(hwnd); HBITMAP bmp = CreateCompatibleBitmap(winDC, width, height);
BITMAPINFO info; BITMAPINFO info;
gfx_ctx_mode_t mode; gfx_ctx_mode_t mode;
SelectObject(dc, bmp);
video_context_driver_get_video_size(&mode); video_context_driver_get_video_size(&mode);
ZeroMemory(&info, sizeof(BITMAPINFO)); 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, StretchDIBits(dc, 0, 0, mode.width, mode.height, 0, 0, width, height,
frame_to_copy, &info, DIB_RGB_COLORS, SRCCOPY); 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_update_window_title();
video_context_driver_swap_buffers(); video_context_driver_swap_buffers();
//UpdateWindow(win32_get_window());
return true; return true;
} }