This hides the 640x480 black loading window, etc.

Reporter: time-killer-games  |  Status: closed  |  Last Modified: October 22, 2017, 01:33:22 PM
  • Before this change, on Windows, there was a 640x480 window, (with a solid-black client area), that would show at immediately after opening your game executable, and it displays however long it takes for the game to initialize everything. I made it so that window stays hidden until everything is initialized, this way there won't be a nasty random 640x480 window at the start of every game.
  • <
Out of curiosity, how long is that "loading window" being displayed? I've never known ENIGMA to spend a noticeable amount of time loading resources. Are you including large audio files, or something?

No, just a very basic game. It takes long enough to load that I can see it, and that's enough reason to make it invisible, honestly. I don't know why anyone would want a random black window at the start of their game, that they can't even resize or modify the visuals thereof. It's easier to just get rid of it, so why not?

and by rid of it I mean make invisible.

The comment was added by me, correctly, in 8d692af where I delayed the showing of the window. The window is not supposed to show until all of the resources have loaded and the graphics context is created to prevent the black window.

This is perhaps not the best place to fix the working directory issue though because, iirc, it's written by the compiler, and simply adding the extra slash should also address the issue for all of the other platforms. So it may be better to just change it there and have it completely fixed everywhere. I haven't tested any of this for regressions yet.


All I know is that black 640×480 window shows at the start of every game, confirmed both on Windows and Linux. But it wouldn't surprise me if was also on Mac. I intend to add a Linux fix, but first I need to see if Josh is ok with these changes.

@RobertBColton I'm fine with making the extra slash a separate PR, I just need to check what file I need to edit, which I will probably do tmr.

My worry is that, if we make this change and someone does make a resource-heavy game, they'll have no indication that the game has actually been launched. We should probably address that by adding a actual loading screen... but that can be done later, I suppose. I'm fine with merging this, assuming that slash behavior is correct.

Ok, so I gave GameMaker 5 some testing. I made a new game with about 60 high resolution 3mb backgrounds and it loaded real slow. With the progress bar in Global Game Settings it just shows the progress bar while loading them and then when the resources are done loading it just instantly displays the game window (no black cut-in). Without the progress bar it just doesn't show anything until the game window finally pops open (no black cut-in). ENIGMA is the exact same, except for a brief split second, the window is black.

With @time-killer-games change here, ENIGMA behaves more like GM5 where the window does not appear until the game is fully loaded. This was the intention of me originally delaying it in the first place, I just didn't put the ShowWindow in the right place.

Now, after testing a few games, I have found a regression. With this change the "Start in Fullscreen" setting no longer works.


@JoshDreamland I think when we add a loading screen, the window shouldn't be stuck at 640×480. it should be whatever size the actual game is supposed to start at, and have a splash screen image show while everything is loading, like how GMStudio does it. And have a way to optionally turn the splash screen off by making it invisible, which GMStudio also does.

I don't want to get too involved with the splash screens just yet Sam, one thing at a time, let's just fix this for now.

Ok, so it seems window_set_fullscreen(true); is broke if you call it in the create event of an object, but not if you call it later on, like so:

if (keyboard_check_released(vk_space)) {


@RobertBColton I know, we don't have to add a splash screen yet, I'm just saying for when we do, that's how it needs to be done.

@RobertBColton I just tested and both window_set_fullscreen(true); in the create event of an object and "Start in fullscreen" GGS are working for me. Are you sure the reason you are having these issues has anything to do with my changes? Because it isn't doing that on my end.

Yes if I move the ShowWindow back where it was and save, it works fine. I have no other local changes. What it's doing is attempting to go fullscreen, but then just displays at normal size with no border because popup style is added.

However, I just realized these changes won't work. The reason is because enigma::initialize_everything() doesn't just initialize graphics, it also fires game_start and goes to the first room. A show_message in game start event in GM5 has the main window visible.


@RobertBColton show_message on Game Start in GMStudio the main game window won't be visible if you have splash screens turned off (which you can only do in the paid version). The window will show after two steps, and since show_message pauses the main loop, it won't be visible until you click "ok". I think we need to target how GMStudio does things, not GM5...

Well, really, we have the compatibility setting too, so we can just do both, with GM:S again being the default. So what I just found out is that something inside initialize_everything() is setting the window visible. Let me see.

Why is fullscreen working for me and not you? I'm really puzzled by this. window_set_fullscreen(true); in the create event, while using my code, I mean...

I'm on Windows 10? It's also possible I have a newer copy of the upstream, but I am not sure because nothing in regards to this has been changed for about 3 years.

Ok, widdled it down to enigma::game_start() making the window visible...


@time-killer-games Add at least one room to the game, it's not reproducible with the default window created by an empty game.

@RobertBColton I did add a room. That's what I did in the first place. I've tried this on Windows 7 and 10.

Hrm, yeah, strange, with one room, your change, Windows 10, start in fullscreen mode, the window is borderless for me:

    //Do not set the parent window visible until we have initialized the graphics context.
    ShowWindow(enigma::hWnd, iCmdShow);

Either way, it seems the whole ShowWindow call is redundant, if I just remove it, then it works with no black cut-in.

I narrowed this down to the following line being responsible for making the window visible before game start:


And the reason is because window_default calls ShowWindow:


@time-killer-games Ok, so basically, just change your pull request to remove the ShowWindow call you changed completely, it's redundant. I was correct in my initial changes to set the window initially invisible though. Please also remove my comment about not showing the window. Then add the following comment to the CreateWindow call please:

    // Create the window initially without the WS_VISIBLE flag until we've loaded all of the resources.
    // This will be handled by game_start in roomsystem.cpp where window_default(true) sets the initial
    // fullscreen state of the window before showing it.
    enigma::hWnd = CreateWindow("EnigmaDevGameMainWindow", "",
                                (enigma::getwindowstyle() & ~(WS_VISIBLE)),
                                (screen_width-wid)/2, (screen_height-hgt)/2, wid, hgt,
                                NULL, NULL, hInstance, NULL);

Also, please just revert the working directory changes for now, we can fix those in a second pr. After that, this should be good to merge.


@RobertBColton done.

Can you copy it from my comment? I tried to format it a little nicer than it was so it wasn't all super-long. Can you undo the working directory stuff and save too? I don't have time to test it atm and I know a better way to fix it, I'd rather do it in a separate pr.

@RobertBColton Ok Robert I did it.

Thanks Sam, and sorry about that, it looks great now!

I wanted to double check GM again but I can't get GM7/GM8 working on Windows 10 and GM:S deprecated the window_default function I am trying to test. This is what I was going to test to verify ENIGMA's behavior:

show_message("main window should be visible...");
show_message("main window should be invisible...");
show_message("main window should be visible? in ENIGMA it is");

Give me a bit to see if I can find a way to run this test in actual GM.


@RobertBColton Well, on Windows 7, using GM 8.1, the window isn't visible in the part where the message says "in ENIGMA it is". Meaning I had to close the game using task manager, because I could no longer see or interact with it. You probably should have game_end() at the bottom of that snippet...

Ok, so not that big of a deal, but we have basically confirmed then that window_default acts slightly different in ENIGMA. The problem is that window_default resets the window style flags, including WS_VISIBLE, and window_set_visible is not modifying that flag but instead using ShowWindow. But that's just a separate bug in these functions, your pull request then is fine, so I am going to merge it.

@RobertBColton Awesome! Thanks a bunch! :D

There we go, thanks again @time-killer-games for helping fix this! The game I tested with the fullscreen was the house effects demo and I just tried it again with this and it works great now.

So just a note on what can be fixed moving forward:

  • window_set_visible could perhaps add/remove WS_VISIBLE from the window's flags so it doesn't get readded
  • window_default resets the window style flags, and calls ShowWindow, it should maybe not do this and just set the WS_VISIBLE flag if it's already set, so it doesn't override window_set_visible

Ok, cool. I'll create the Linux version of this PR now. On Linux there is a black 640x480 window as well, but I already know how to fix it, just let my fire up my Ubuntu laptop to check it out. :)
Please sign in to post comments, or you can view this issue on GitHub.