From 2b969892e6fd23625951b017e2d8efa0825edb5a Mon Sep 17 00:00:00 2001 From: Nelson Gomez Date: Sat, 19 Oct 2024 01:57:48 -0700 Subject: [PATCH] Mark framebuffer reads from the dirty rect backing buffer --- scgl/cGDriver.h | 1 + scgl/cGDriver_Viewport.cpp | 1 + scgl/ext/cGDriver_BufferRegions.cpp | 14 +++++++------- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/scgl/cGDriver.h b/scgl/cGDriver.h index fcc33f2..905115b 100644 --- a/scgl/cGDriver.h +++ b/scgl/cGDriver.h @@ -102,6 +102,7 @@ namespace nSCGL void* secondaryWindow; void* secondaryDeviceContext; void* pixels; + void* lineBrush; #endif private: diff --git a/scgl/cGDriver_Viewport.cpp b/scgl/cGDriver_Viewport.cpp index edd414a..6a33265 100644 --- a/scgl/cGDriver_Viewport.cpp +++ b/scgl/cGDriver_Viewport.cpp @@ -251,6 +251,7 @@ namespace nSCGL ShowWindow(secondaryHwnd, SW_SHOWNORMAL); pixels = new char[3 * newMode.width * newMode.height]; + lineBrush = CreateSolidBrush(RGB(255, 0, 0)); } #endif diff --git a/scgl/ext/cGDriver_BufferRegions.cpp b/scgl/ext/cGDriver_BufferRegions.cpp index af0220e..9f452b2 100644 --- a/scgl/ext/cGDriver_BufferRegions.cpp +++ b/scgl/ext/cGDriver_BufferRegions.cpp @@ -112,11 +112,8 @@ namespace nSCGL InvalidateRect((HWND)secondaryWindow, nullptr, TRUE); PAINTSTRUCT ps; - DWORD dwError; HDC hdc = BeginPaint((HWND)secondaryWindow, &ps); - dwError = GetLastError(); - BITMAPINFO bm; bm.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bm.bmiHeader.biWidth = width; @@ -134,7 +131,7 @@ namespace nSCGL bm.bmiColors->rgbRed = 255; bm.bmiColors->rgbReserved = 0; - dwError = ::SetDIBitsToDevice( + ::SetDIBitsToDevice( hdc, dstX0, windowHeight - dstY1, @@ -148,11 +145,14 @@ namespace nSCGL &bm, DIB_RGB_COLORS); - dwError = GetLastError(); + RECT rect; + rect.left = srcX0; + rect.right = rect.left + width; + rect.top = windowHeight - dstY1; + rect.bottom = rect.top + height; + FrameRect(hdc, &rect, (HBRUSH)lineBrush); EndPaint((HWND)secondaryWindow, &ps); - - dwError = GetLastError(); } #endif