E
EulogyForTheFallen
Guest
Hello good people of the forum, I have an interesting problem that I've been trying to fix for a while now and I think I'm going to lose my mind. Basically, the problem is with scaling. I've read every tutorial and article on the subject, and none of them helped me. The problem is this: My target resolution is 1080p, and as such all of the rooms' view_wview and view_hview settings are set to 1920x1080. I have a master object that is placed in the first room (screenSplash) with the room editor, and in this object's Game Start event I run this script:
This works just fine on my laptop's 1080p screen. The problem is that when I try it on my 1280x1024 monitor and use debug messages to print the values of view_wview and view_hview, they tell me the correct values: 640x512. But when I actually play the game, it looks like this:
The red rectangle is a debug draw that represents the view. If my script was working correctly, it should be drawn around the edges of the screen. Here is the code I use to draw it and the grid:
So clearly my script changes the values of view_wview and hview, along with wport and hport because debug statements confirm it and the red rectangle is drawn correctly. But somehow, even though the values were changed, the game still uses the 1080p values for the actual view. Does anyone have any idea why this is happening? I'm using GM:S v1.4.1757 on Windows 10. Thanks
Code:
var ww = window_get_width();
var hh = window_get_height();
var xx = window_get_x();
var yy = window_get_y();
var ar = hh/ww;
display_reset(0,false);
display_set_windows_alternate_sync(true);
if(ww > 2048){ //If the player has a very high resolution, play at 1 to 3.
view_wview[0] = ww/3;
view_hview[0] = hh/3;
}else if(ww > 960){ //If the player has a decently high resolution, play at 1 to 2.
view_wview[0] = ww/2;
view_hview[0] = hh/2;
}else{ //If the player has a low resolution, play at 1 to 1.
view_wview[0] = ww;
view_hview[0] = hh;
}
view_wport[0] = ww;
view_hport[0] = hh;
display_set_gui_size(1920, 1920*ar);
surface_resize(application_surface, ww, hh);
if(room == screenSplash){
room_width = view_wview[0];
room_height = view_hview[0];
var i = true;
var rm = room_next(room);
while (i){
room_set_view(rm, 0, true, 0, 0, view_wview[0], view_hview[0], 0, 0, view_wport[0], view_hport[0], view_wview[0]/2, view_hview[0]/2, -1, -1, obj_act);
room_set_view_enabled(rm,true);
if(rm == room_last){
i = false;
}else{
rm = room_next(rm);
}
}
show_debug_message("All rooms' views set.");
}
show_debug_message("Width: " + string(ww));
show_debug_message("Height: " + string(hh));
The red rectangle is a debug draw that represents the view. If my script was working correctly, it should be drawn around the edges of the screen. Here is the code I use to draw it and the grid:
Code:
//Draw rectangle to test screen dimensions.
draw_set_color(c_red);
draw_rectangle(view_xview[0],view_yview[0],view_xview[0]+view_wview[0],view_yview[0]+view_hview[0],true);
///DRAW 32x32 GRID
draw_set_color(c_black);
for(var xPos = -1; xPos < room_width; xPos += 32)
draw_line_color(xPos,0,xPos,room_height,c_black,c_black);
for(var yPos = -1; yPos < room_height; yPos += 32)
draw_line_color(0,yPos,room_width,yPos,c_black,c_black);