Note that it isn’t doing the actual resize handling in the event code, so that if multiple resize events happen in one frame we don’t waste time doing a bunch of extra work.
Thanks! It works for preventing the window twitching but the image inside is still getting corrupted inside. I couldn’t find anything specifically regarding this in the wiki.
Thanks! It works like a charm! How did you figure it out?
I couldn’t find anything regarding this in the wiki.
So the correct way to handle resize would be:
Get the window surface again
Clear the screen or set it to the initial surface colour
Redraw the contents onto the new surface
Am I missing something else?
Also, should I also check for window events like SDL_WINDOWEVENT_EXPOSED along with SDL_WINDOWEVENT_RESIZED and SDL_WINDOWEVENT_SIZE_CHANGED when the window size is changed?
Once I saw it in action it was pretty obvious; I’ve run into issues doing my own software blitting before where I was calculating the offset of a line wrong and got similar results. And it stands to reason that if you have junk on the screen in the parts where you aren’t drawing then you need to clear those parts.
You don’t need to check for SDL_WINDOWEVENT_EXPOSED as part of the resize logic. It’s unrelated to resizing, however it wouldn’t be a bad idea to handle as many window events as appropriate for your app. If I wasn’t posting from my phone I’d dig up the link on the wiki that has all the window events.