• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Cannot get GUI scaling right...

ajrdesign

Member
I'm pulling my hair out with this. I cannot for the life of me figure out why my GUI is scaling incorrectly and creating sub pixels. Here's some examples: https://imgur.com/a/DU4uE6G

If I set my GUI to full device size it renders them fine but any sort of aspect ratio scaling I try to do (because I don't want my GUI to be drastically different sizes on different devices) breaks it.

Here's the code that's running at the beginning of the game to set up display:

Code:
global.monitor_w = display_get_width()
global.monitor_h = display_get_height()

/// Display properties
global.view_width =        0;
global.view_height =    360
show_debug_message("Total display height: " + string(display_get_height()) +" View height set: " +  string(vheight))
global.ui_scale = 2;

global.camera_x = 0
global.camera_y = 0

aspect_ratio = display_get_width() / display_get_height();
show_debug_message_ext("Aspect ratio: " + string(aspect_ratio))
global.view_width = global.view_height*aspect_ratio;

//Check to make sure our ideal width and height isn't an odd number, as that's usually not good.

if(global.view_width & 1)
  global.view_width++;
   
if(global.view_height & 1)
  global.view_height++;

//Setup all the view ports so I don't have to.
globalvar Main_Camera;
Main_Camera = camera_create_view(0,0,global.view_width,global.view_height,0,noone,0,0,0,0);
camera_set_view_size(Main_Camera,global.view_width,global.view_height);

for(var i=1; i<= room_last; i++)
{
  if(room_exists(i))
  {   
       room_set_view_enabled(i,true);
       room_set_viewport(i,0,true,0,0,global.view_width,global.view_height);
       room_set_camera(i,0,Main_Camera);
  }
}

surface_resize(application_surface,global.view_width,global.view_height);
global.gui_height = vheight*uiscale
global.gui_width = (vheight*aspect_ratio)*uiscale
//display_set_gui_size(global.gui_width,global.gui_height);
window_set_size(global.view_width*uiscale,global.view_height*uiscale);
Any help in identifying what I'm doing that's causing this would be appreciated!
 
J

Jordan Robinson

Guest
I'm pulling my hair out with this. I cannot for the life of me figure out why my GUI is scaling incorrectly and creating sub pixels. Here's some examples: https://imgur.com/a/DU4uE6G

If I set my GUI to full device size it renders them fine but any sort of aspect ratio scaling I try to do (because I don't want my GUI to be drastically different sizes on different devices) breaks it.

Here's the code that's running at the beginning of the game to set up display:

Code:
global.monitor_w = display_get_width()
global.monitor_h = display_get_height()

/// Display properties
global.view_width =        0;
global.view_height =    360
show_debug_message("Total display height: " + string(display_get_height()) +" View height set: " +  string(vheight))
global.ui_scale = 2;

global.camera_x = 0
global.camera_y = 0

aspect_ratio = display_get_width() / display_get_height();
show_debug_message_ext("Aspect ratio: " + string(aspect_ratio))
global.view_width = global.view_height*aspect_ratio;

//Check to make sure our ideal width and height isn't an odd number, as that's usually not good.

if(global.view_width & 1)
  global.view_width++;
  
if(global.view_height & 1)
  global.view_height++;

//Setup all the view ports so I don't have to.
globalvar Main_Camera;
Main_Camera = camera_create_view(0,0,global.view_width,global.view_height,0,noone,0,0,0,0);
camera_set_view_size(Main_Camera,global.view_width,global.view_height);

for(var i=1; i<= room_last; i++)
{
  if(room_exists(i))
  {  
       room_set_view_enabled(i,true);
       room_set_viewport(i,0,true,0,0,global.view_width,global.view_height);
       room_set_camera(i,0,Main_Camera);
  }
}

surface_resize(application_surface,global.view_width,global.view_height);
global.gui_height = vheight*uiscale
global.gui_width = (vheight*aspect_ratio)*uiscale
//display_set_gui_size(global.gui_width,global.gui_height);
window_set_size(global.view_width*uiscale,global.view_height*uiscale);
Any help in identifying what I'm doing that's causing this would be appreciated!
I might be understanding your problem incorrectly, but I will do my best to help narrow it down. You want the GUI to look the same on different devices regardless of the scaling?
If this is correct, then you should be able to just set the base game resolution.

i.e display_set_gui_size(global.view_width,global.view_height);

It is a little hard to tell however, as I can see some references to the variables vheight and I can't see where that is assigned... Feel free to PM me, I might be able to give better feedback after discussing the issue further with you
 
Top