• 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 change resolutions without pixel distortion?

A

alex19735

Guest
Hi, I am writing to ask about something I've been battling for a while. I want my game to use the resolution of the player's screen, but also remain the same scale. I don't want the game to look more zoomed out on larger resolutions. I do this by setting the camera's view size to the base resolution of my game (1280 by 720). This works well, however when scaling to, say, 1920x1080, the pixels get distorted, because 1920x1080 divided by 1280x720 is 1.5. How can I scale the game view to match the device's resolution, without getting pixel distortion?

Code:
view_wport[0] = displayWidth;
    view_hport[0] = displayHeight;
    
    if (view_get_wport(0) != displayWidth){
        view_set_wport(0, baseWidth);
        view_set_hport(0, baseHeight);
        camera_set_view_size(view_camera[0], baseWidth, baseHeight);
    }
    if (surface_get_height(application_surface)!=displayHeight){
        surface_resize(application_surface, displayWidth, displayHeight);
    }
This is the game in windowed mode, where there is no scaling:
game_normal.png

And here it is in fullscreen, scaled to 1920x1080:
game_distorted.png

I've noticed that the GUI Layer does not suffer from this problem, and it scales perfectly! So surely there must be a way to scale 1280x720 to 1920x1080 without any pixel distortion?

Thank you in advance, and sorry if I explained things badly, I don't really know how to word this any better.
 
I recommend the following tutorials as a good starting point to understanding and managing your games resolution.

How to properly scale your game!


Scaling, Resolution, and Aspect Ratio Management for GMS1 & GMS2


Basically if you want to scale a pixel perfect game without distortion, you must scale your resolution by an integer factor, e.g. 1,2,3,4...etc...

If your games resolution doesn't fit neatly into the devices resolution, as in your example of 1280x720 not fitting in to 1920x1080, you need to scale it up to the nearest best fit integer multiple and have black bars or other graphics filling the borders.

But the above links will explain it much better than I have tried to do briefly here.
 
A

alex19735

Guest
That really is a bummer. I have read those guides before and I understand why this happens, it's just really frustrating because I obviously want to make it look as good as possible on any device configuration.

Is there any way to scale the actual game contents without scaling the view? Like scaling the game objects or something like that. If not, I guess I will have to compromise and use black bars.

Thank you in advance!
 

NightFrost

Member
Well if you understand why it happens, then you should also realize that full, smooth scaling of any random room size is not possible, because pixels. Best you can do is to mitigate the effects. Choose a low resolution for your view which has the most common display res (1920x1080) as its integer multiplier result, for example 480x270 (x4) or 640x360 (x3). Large scaling means on displays not of integer scale factor the added pixel stretch is not easily noticeable. Or calculate the largest integer multiplied size that fits display and scale with that, leaving black borders all around. Maintain aspect ratio so there's no additional stretching, which means on displays not of 16:9 aspect you add black bars.

EDIT or do a combination of integer scaling and adjusted view size. That is, calculate the largest integer scale multiplier and then adjust view size to fill the screen. I recall Sunless Sea does this, at least I seem to remember when you use different display resolutions, the distance how far around your ship you can see changes (meaning playing at certain display resolutions offers a view distance advantage).
 
Last edited:

RangerX

Member
That really is a bummer. I have read those guides before and I understand why this happens, it's just really frustrating because I obviously want to make it look as good as possible on any device configuration.

Is there any way to scale the actual game contents without scaling the view? Like scaling the game objects or something like that. If not, I guess I will have to compromise and use black bars.

Thank you in advance!
Today you learned that a game that looks good is a game with no distorted graphics. Sorry you can't have both full scale and no distortion but if ever you want a relief, no games ever in the history of making games did that because its a purely logic limitation of pixels based screens. And no game ever in the futur of forever into infinity will do it for as long as its displayed in a pixel based screen. :)
 
Top