• Hey! Guest! The 37th GMC Jam will take place between May 28th, 12:00 UTC and June 1st, 12:00 UTC. Why not join in! Click here to find out more!

GML How can I make viewport smaller than window size?

Xalezar

Member
Been trying to make my viewport 0 smaller than the game window, but whatever size I set the viewport to, it becomes stretched to fill the game window, so it ends up being distorted (stretched out vertically). What I've done so far in my mgr_camera persistent object that is instantiated at the start of the game in room rm_init, which has dimensions 160 x 284. Immediately after mgr_camera is instantiated, the player is transported to a new map where he can walk around.



What I've attempted so far:

Code:
/* Create */

camera = camera_create();

/* Room Start */

view_enabled = true;
view_visible[0] = true;

view_xport[0] = 0;
view_yport[0] = 0;

view_wport[0] = 160;
view_hport[0] = 160;

view_camera[0] = camera;

var pm = matrix_build_projection_ortho(view_wport[0], view_hport[0], -9999, 9999);
camera_set_proj_mat(camera, pm);

var vm = matrix_build_lookat(view_wport[0]/2, view_hport[0]/2, -10, view_wport[0]/2, view_hport[0]/2, 0, 0, 1, 0);
camera_set_view_mat(camera, vm);
Any help is appreciated, thanks.
 
Last edited:

Relic

Member
In addition to this code, have you checked the settings of your game? In the resource tree the Main item has a graphics tab - check whether your game is resizing to fit the window or keeping aspect ratio.

The camera code itself I can’t debug from memory alone sorry.
 

Xalezar

Member
In addition to this code, have you checked the settings of your game? In the resource tree the Main item has a graphics tab - check whether your game is resizing to fit the window or keeping aspect ratio.

The camera code itself I can’t debug from memory alone sorry.
Yeah, the maintain ratio is checked off.
 

Relic

Member
I hear you - just marked 60 test papers asking whether an alarm was on or off. So many “the alarm goes off” phrases. Is that on or off? Lol
 

samspade

Member
Last edited:

Xalezar

Member
I see, thanks for sharing your experiences with this issue. I think a possible easier workaround for me might be just to use the whole screen, but cover up the portion where I want it to be blank. I think performance will be negligible. Context: the area that I want to be left blank, will be used to accept touch gestures so that the player's fingers don't obscure the camera view. Just trying out this user interface to see how it feels.
 
Top