From a8baf36477195b9a3cc4726180378c8afa9336b3 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Wed, 1 Oct 2025 06:47:08 +0000 Subject: [PATCH] better rendering git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@99 b9cfdab3-6d41-4d17-bbe4-086880011989 --- include/Mw/GDI.h | 2 +- src/gdi.c | 35 +++++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/include/Mw/GDI.h b/include/Mw/GDI.h index ce1a24c..a61c600 100644 --- a/include/Mw/GDI.h +++ b/include/Mw/GDI.h @@ -17,7 +17,7 @@ struct _MwLL { HWND hWnd; HDC hDC; void* user; - int copy_buffer; + int copy_buffer; MwLLHandler handler; }; diff --git a/src/gdi.c b/src/gdi.c index c422f9a..c9f323a 100644 --- a/src/gdi.c +++ b/src/gdi.c @@ -17,23 +17,29 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { HBITMAP hbmp; HDC dc, hbdc; - GetClientRect(hWnd, &rc); + if(u->ll->copy_buffer) { + GetClientRect(hWnd, &rc); - dc = GetDC(hWnd); - hbmp = CreateCompatibleBitmap(dc, rc.right - rc.left, rc.bottom - rc.top); - hbdc = CreateCompatibleDC(dc); - SelectObject(hbdc, hbmp); - ReleaseDC(hWnd, dc); + dc = GetDC(hWnd); + hbmp = CreateCompatibleBitmap(dc, rc.right - rc.left, rc.bottom - rc.top); + hbdc = CreateCompatibleDC(dc); + SelectObject(hbdc, hbmp); + ReleaseDC(hWnd, dc); - u->ll->hDC = hbdc; - MwLLDispatch(u->ll, draw); + u->ll->hDC = hbdc; + MwLLDispatch(u->ll, draw); - dc = BeginPaint(hWnd, &ps); - StretchBlt(dc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, hbdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SRCCOPY); - EndPaint(hWnd, &ps); + dc = BeginPaint(hWnd, &ps); + StretchBlt(dc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, hbdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SRCCOPY); + EndPaint(hWnd, &ps); - DeleteDC(hbdc); - DeleteObject(hbmp); + DeleteDC(hbdc); + DeleteObject(hbmp); + } else { + u->ll->hDC = BeginPaint(hWnd, &ps); + MwLLDispatch(u->ll, draw); + EndPaint(hWnd, &ps); + } } else if(msg == WM_LBUTTONDOWN) { SetCapture(hWnd); MwLLDispatch(u->ll, down); @@ -82,7 +88,8 @@ MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height) { RegisterClassEx(&wc); - r->hWnd = CreateWindow(parent == NULL ? "milsko" : "STATIC", "Milsko", parent == NULL ? (WS_OVERLAPPEDWINDOW) : (WS_CHILD | WS_VISIBLE), x, y, width, height, parent == NULL ? NULL : parent->hWnd, 0, wc.hInstance, NULL); + r->copy_buffer = 1; + r->hWnd = CreateWindow(parent == NULL ? "milsko" : "STATIC", "Milsko", parent == NULL ? (WS_OVERLAPPEDWINDOW) : (WS_CHILD | WS_VISIBLE), x, y, width, height, parent == NULL ? NULL : parent->hWnd, 0, wc.hInstance, NULL); u->ll = r; if(parent == NULL) {