SOLVED Window suddenly breaking when swapping from fullscreen to windowed resolutions

Zahk

Member
So I've had this code in my game for a while - haven't changed it at all - but today I decided to change the resolution in my game's options menu and discovered that it appears to be broken suddenly. Here's what happens:

I swap the game from fullscreen to a lower resolution (in this case, 160x144), but instead of simply leaving fullscreen and shrinking the window down, it shrinks to a distorted resolution in a borderless window, then begins repeatedly flashing white while gradually expanding horizontally over a span of about 5 seconds, until finally it stretches out and becomes an unnecessarily wide, bordered window in an incorrect (fullscreen-sized) resolution. (edit: I just discovered that the window it's stretching to is exactly the length of both of my monitors combined... I don't know what that means, or how to fix it).

This ONLY happens if the game was previously set to fullscreen. If I don't set it to fullscreen first, then it correctly changes to the appropriate resolutions.

Here is my current code for changing from fullscreen to the minimum resolution:

GML:
window_set_fullscreen(false);
display_set_gui_size(160, 144);
window_set_size(160, 144);
My project searches didn't turn up any other code that could be messing with the window's size at all. Did one of gamemaker's updates bust some of these functions? Or could I be missing something here? It worked fine when I implemented it, and haven't messed with resolutions at all since then.
 
Last edited:
Pretty sure you need to wait a few frames after changing the fullscreen settings before adjusting window size and other stuff like that.
 

Zahk

Member
Pretty sure you need to wait a few frames after changing the fullscreen settings before adjusting window size and other stuff like that.
Well, I added in a 10 frame alarm to trigger the window size change, and it seems to be working now.

I don't know whether to be glad that it works, or mad that it is yet another instance where it seemed to be working fine before, and then suddenly broke, and the solution is some obscure bull**** that there's no way for me to have known about without coming to make a post here on the forums.

I don't think I'll ever truly enjoy coding, if only because of stuff like this, lmao.

Either way, thank you for the fix! I can at least move on now, and hope nothing else that I already set up and tested randomly breaks yet again.

I really appreciate it.
 
Yeah, there's definitely room for improvement in the manual in regards to subtleties like this. The real secret is to troll the forums 24/7 so that whenever nuggets of information like this randomly pop up you learn about it ;)
 

Zahk

Member
I think I'll just keep plodding along and then get irrationally angry when something breaks for no apparent reason and come have a tantrum here once in a while, it's been working so far.
 

Karlstens

Member
Uh-oh, I wonder if what you've discussed here is the problem that I've encountered - where for the first 10 frames of my game using window_set_size(room_width*3, room_height*3) that within a Draw GUI event, Draw_Rectangle, Vertex, and Primitive commands work as expected until then at frame 10 - the scaling of the Draw GUI layer incorrectly collapses back to the monitor resolution - resulting in a GUI scaled to a monitor, and an application surface in a game window remaining correct at a scale of 3.

You've mentioned an alarm that kicks into gear at frame 10, but for me, the opposite is happening, in my game looks correct until frame 10...

Any thoughts?
 
Top