• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

GMS 2.3+ Window size change and fullscreen problem...



I am under Windows 10.

For the moment I was developping my game in a window smaller than my Full HD display, with an application surface of the same size as the window. No problem. Everything is 1:1, crisp and clear.

Now I would like to change window size within the game if needed (custom graphical options), and also possibly going to fullscreen or "windowed borderless fullscreen" without exiting the game.

From what I read and understand, I made this little test program here :
(use SPACE to change window size and F to toggle fullscreen)

My problems :
1 - window size is changing correctly for "small sizes", but when I try to give it the size of the display (in my case 1920x1080), it seems that I cannot obtain this size but 1920x1061... And as I resized the surface and room to 1920x1080, there is a slight distorsion which gives problems (you can see it on the diagonals of the moving objects that are aliased or the upper text that is a bit cropped). I don't understand why I cannot get this window size. (my secret goal would be to obtain a full size window, like a "windowed borderless fullscreen").

2- If I use F to switch to fullscreen, after a disturbing screen resolution flip, I obtain a good result. But then if I press F again to go back to windowed mode, I discover that under Windows, my desktop is all messed up, as if the resolution was changed in between (windows size are reduced, firefox displays big fonts, etc...). Strange. That's a problem that I never encounter with other games when I switch to fullscreen... So what am I doing wrong ? I suspect that the order of my commands or the timing might be a problem ?

3- another strange detail : at the end of the draw event of the obj_screen, I draw 2 rectangles around the room to visualize the room limits. It is strange that the first red rectangle is not visible, no ?...

How are you dealing with this window size change in the graphical options of your game ? Can you help me with these problems ?


Am I suppose to post a YYZ file here ? maybe not... So here is my code, if you have any idea what is wrong...

// press SPACE to change window size
// press F to toggle fullscreen on/off

wdisp = display_get_width();
hdisp = display_get_height();

scales = [0.4,0.6,0.8,1.0];
n_scale = 0;

function resize_window()
        w = wdisp;
        h = hdisp;
        w = wdisp * scales[n_scale];
        h = hdisp * scales[n_scale];

    room_width = w;
    room_height = h;
    alarm[0] = 2;   // window center if needed

    // reposition objects inside window
/// @description change window size

    if(n_scale == array_length(scales)) n_scale = 0;

/// @description toggle fullscreen


/// @description draw border and text

draw_text(0,20 ,"FPS real " + string(fps_real) + " FPS " + string(fps) );
draw_text(0,40 ,"DISPLAY " + string(display_get_width()) + "x" + string(display_get_height()) );
draw_text(0,60 ,"WINDOW " + string(window_get_width()) + "x" + string(window_get_height()) );
draw_text(0,80 ,"SURFACE " + string(surface_get_width(application_surface)) + "x" + string(surface_get_height(application_surface)) );
draw_text(0,100,"ROOM " + string(room_width) + "x" + string(room_height) );
draw_text(0,200,"SPACE: change window size, F: toggle fullscreen");

// should be the border of the window....

// no : this is the real border !


I don't know if this is what you're looking for but, this is what I ended up with trying to get scaling done myself.

/// @description Init Display
//Setting up ideal ratios
ideal_width = 0;
ideal_height = display_get_height();

aspect_ratio = display_get_width() / display_get_height();


//Check for odd numbers
if(ideal_width & 1)
//Enable the use of views
    target_view = 0;
    view_enabled = true;

//Make view 0 visible
view_set_visible(target_view, true);

//Set the port bounds of view 0 to ratio
view_set_wport(target_view, ideal_width);
view_set_hport(target_view, ideal_height);

//Resize and center
window_set_rectangle((display_get_width() - view_wport[target_view]) * .5, (display_get_height() - view_hport[target_view]) * 0.5, view_wport[target_view], view_hport[target_view]);

//Camera creation
//Build a camera at (0,0), ratio based on display height, 0 degrees of angle, no target instance, instant-jupming hspeed and vspeed, with a 32 pixel border
camera = camera_create_view(0, 0, 320, 240, 0, obj_Player, -1, -1, ideal_width/2, ideal_height/2);

//Set view0 to use the camera "camera"
view_set_camera(target_view, camera);
you can change the ideal_height to whatever you want but, I chose just the display height. It checks for the height of the display and sets the width based on that. It also checks to see if the resolution is an even number and if not makes it so it is. Then it centers the display on screen and centers the camera on the obj_player object which you can change to whatever object. Is this roughly what you're aiming for?


@Grobinson Hi and thanks for your help. My needs are more simple because I use the default camera, so no viewport and so on. But basically I do the same as you do, and everything works fine as long as I stay with a bordered window smaller than the screen display. My problem is when I try to make a fullscreen game :

- if I use the true fullscreen (window_set_fullscreen true) then there is a hard disgraceful transition (weird resolution flip) before entering fullscreen mode, and when coming back to windowed mode (window_set_fullscreen false), my windows 10 desktop is all messed up (windows resized, fonts with problems).

- that's why I'd like to use a "borderless windowed fullscreen" mode instead, which is proposed by most of the games on the market, and which is very handy because you can switch flawlessly between the desktop and the game. But I do not succeed in getting such a mode. Trying to give the GMS window the size of the display (1920x1080 in my case), results in a problem : GMS only gets 1920x1061 in return.

- if you have the opportunity, can you run the YYZ I provided and tell me what is the result for you, pressing SPACE until the window covers the screen ?

I'd really like to get this "borderless windowed fullscreen" in the graphical options of my game (but also a classic "small bordered window")...