Skip to content

[rcore][win32] Fix crash when resizing the software renderer - #6332

Merged
raysan5 merged 1 commit into
raysan5:masterfrom
Ne0nWinds:win32-rlsw-crash
Oct 28, 2026
Merged

raysan5 merged 1 commit into
raysan5:masterfrom
Ne0nWinds:win32-rlsw-crash

Conversation

@Ne0nWinds

@Ne0nWinds Ne0nWinds commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

This PR fixes two different, yet related, issues that occurred when resizing the window with the software rasterizer enabled.

1. Underlying bitmap not resized

When the software rasterizer is enabled, the underlying window bitmap was not resized. If the window was resized to be smaller, the image would look garbled. If the window became larger, the application would crash from reading past the end of the bitmap.

Fix: Whenever the window width/height changes, resize the GDI bitmap the underlying GDI bitmap

2. WM_SIZE event ordering

This PR also fixes a hack that was put in place due to the ordering of Windows events. Upon window creation, Windows sends a WM_SIZE event (and potentially other related events like WM_GETDPISCALEDSIZE and WM_DPICHANGED). This is problematic because WndProc can call HandleWindowResize, which in turn, calls SetupViewport and swResize.

The software rasterizer is not initialized when InitPlatform is called, so calling SetupViewport or swResize will crash the program. In fact, there's already a hack in the WM_SIZE event to prevent this: if (CORE.Time.frameCounter > 2)

Fix: In this PR, I simply defer calling SetupViewport and swResize until PollInputEvents. The software rasterizer is guaranteed to be initialized by the time PollInputEvents is called, so we don't need to put any special cases into the event handlers

Comment thread src/platforms/rcore_desktop_win32.c Resolved
Comment thread src/platforms/rcore_desktop_win32.c Resolved
Comment thread src/platforms/rcore_desktop_win32.c Resolved
@raysan5
raysan5 merged commit f2939a6 into raysan5:master Oct 28, 2026
16 checks passed
@raysan5

raysan5 commented Oct 28, 2026

Copy link
Copy Markdown
Owner

@Ne0nWinds Nice improvement! Thanks!

@Ne0nWinds
Ne0nWinds deleted the win32-rlsw-crash branch October 28, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants