• 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 How to properly scale surfaces

hth

Member
So, my prototype is running in 360p. That's the resolution all the assets are created and the main view is configured for. If I apply surface_resize() to the application surface like this:

Code:
surface_resize(application_surface, display_get_width(), display_get_height());
GMS scales the image properly when I, say, double or triple the window size or go full-screen. Properly meaning GMS renders in the display's native resolution, and the sprites don't look blocky when rotated. This is how it looks like with the window size tripled (1080p):

RTX on: rtx_on.png

Which is exactly as intended. The problem I have is when I draw surfaces. Depending on game mode, I have a split-screen situation going on, and everything works as it should EXCEPT that the surface doesn't scale the same way as the application surface does, and sprites, when rotated or resized, are blocky like this:

RTX off: rtx_off.png

I fine-combed the manual for the past few days, I played around with viewport dimensions and surface_resize(), but I don't seem to be able to actually understand how scaling works. For the application surface, GMS seems to do all the work automatically, and the information on what exactly it does so that one could reproduce it are sparse.

I can of course provide code to show how exactly I configure views, cameras and surfaces, but as I currently don't know what's important and what's not, I'm gonna leave it out for now and wait for somebody to give me more input on what I am probably doing wrong. Any help greatly appreciated.
 

Kyon

Member
Yeah so, I think there is something wrong with how gamemaker resizes the application surface automatically.
I actually resize it manually when switching full screen.
So at the point the window is going full screen, I just resize the application surface, and the width/height is display_get_width() / height().

Try if that works for you too.
 

hth

Member
You mean calling
Code:
surface_resize(application_surface, display_get_width(), display_get_height());
again after window size has changed? No, that doesn't do anything.
 
What is the size of your surface, and the size of your window? Check at run time if you aren't completely sure.

So, you are drawing a new surface. But are you still using the application surface at all?

What does RTX mean exactly?
 

hth

Member
What is the size of your surface, and the size of your window? Check at run time if you aren't completely sure.
Application-surface width is the same as display width, both 2560 px in my case. That's as expected, as I deliberately resize it to that on game start. If it helps, this is pretty much all of the relevant code:
Code:
// Supporting any common widescreen aspect ratio, i. e. anything between 16:10 and 21:9.

var ideal_width;
var ideal_height = GM_Y_RESOLUTION;
var display_width = display_get_width();
var display_height = display_get_height();
var window_size_modifier = 1;
var aspect_ratio = clamp(display_width / display_height, GM_RATIO_MIN, GM_RATIO_MAX);

// Making sure ideal width and height aren't odd numbers.

ideal_width = round(ideal_height * aspect_ratio);
if (ideal_width & 1)  ideal_width++;
if (ideal_height & 1) ideal_height++;

// Resize game window, application surface and GUI.

surface_resize(application_surface, display_width, display_height);
display_set_gui_size(ideal_width, ideal_height);
window_set_size(ideal_width * window_size_modifier, ideal_height * window_size_modifier);
And GOD DAMN IT, just as I'm re-reading this again, the display_set_gui_size() catches the eye. As the second surface is drawn via Draw GUI, this might have something to do with the problem. Gonna have a look at that.
So, you are drawing a new surface. But are you still using the application surface at all?
Yes, like I said, it's split-screen situation. The second surface is drawn on the right side of the screen via Draw GUI. This is how that currently looks:

debris.png

Right half of the screen is the surface showing the second view. All working as intended except for the scaling. Again, the relevant code for surface creation:
Code:
var cam_2_w = global.viewport_width / 2;
var cam_2_h = global.viewport_height;

global.p2_camera_split = camera_create_view(0, 0, cam_2_w, cam_2_h, 0, noone, 0, 0, 0, 0);
view_set_visible(VW_SECONDARY, true);
view_set_camera(VW_SECONDARY, global.p2_camera_split);

p2_surface_split = surface_create(cam_2_w, cam_2_h);
view_set_surface_id(VW_SECONDARY, p2_surface_split );
surface_set_target(p2_surface_split );
surface_reset_target();
What does RTX mean exactly?
Nothing, just a not-so-clever joke. ;-)
 

hth

Member
And GOD DAMN IT, just as I'm re-reading this again, the display_set_gui_size() catches the eye. As the second surface is drawn via Draw GUI, this might have something to do with the problem. Gonna have a look at that.
This is why, whenever I have a GMS-related problem, I should type down a forum post and then not publish it for a while. Turns out that was, in fact, the issue. All works as it should now.
 
Top