Repository navigation
[rcore][win32] Fix crash when resizing the software renderer - #6332
Merged
Merged
Conversation
Ne0nWinds
commented
Oct 25, 2026
Ne0nWinds
commented
Oct 25, 2026
Ne0nWinds
commented
Oct 25, 2026
Owner
|
@Ne0nWinds Nice improvement! Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_SIZEevent (and potentially other related events likeWM_GETDPISCALEDSIZEandWM_DPICHANGED). This is problematic becauseWndProccan callHandleWindowResize, which in turn, callsSetupViewportandswResize.The software rasterizer is not initialized when
InitPlatformis called, so callingSetupViewportorswResizewill crash the program. In fact, there's already a hack in theWM_SIZEevent to prevent this:if (CORE.Time.frameCounter > 2)Fix: In this PR, I simply defer calling
SetupViewportandswResizeuntilPollInputEvents. The software rasterizer is guaranteed to be initialized by the timePollInputEventsis called, so we don't need to put any special cases into the event handlers