• 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 to maintain correct aspect ratio at fullscreen (using application_surface)?

hdarren

Member
Usually in GameMaker if you go fullscreen then it adds a nice black letterbox to maintain correct aspect ratio so that pixels aren't distorted if you ticked that box in the options. But if you turn off the application surface to draw it yourself then it doesn't do this automatically, instead it just stretches it to the complete fullscreen creating ugly pixels.

I'm drawing the application surface myself so I can do things to it like I got some cool shaders from the market place. :)

This is the code I'm using in my object that now draws the application surface, it is the Post-Draw event

Code:
if global.vFullscreen {var a=application_get_position(); xx=a[0]; yy=a[1]; ww=a[2]-a[0]; hh=a[3]-a[1];}
else {xx=0; yy=0; ww=global.vResolution_Width; hh=global.vResolution_Height;}

draw_surface_stretched_ext(application_surface,xx,yy,ww,hh,-1,1);
I'm having a lot of trouble trying to figure out the maths of how to maintain the aspect ratio correctly.

I couldn't find much from searching but I did find this topic which had some code to do this but it doesn't seem to do anything.
https://forum.yoyogames.com/index.php?threads/how-do-i-get-clean-and-crisp-screen-resolution-in-game-maker.54482/#post-331430

Any help appreciated! :)
 

hdarren

Member
No. The problem is the resized surface is the full fullscreen size so if your desktop resolution can't be multiplied into my game's resolution of 256x144 it skews the pixels. I want it so in fullscreen the aspect ratio is kept to the 256x144 ratio.
 

rIKmAN

Member
No. The problem is the resized surface is the full fullscreen size so if your desktop resolution can't be multiplied into my game's resolution of 256x144 it skews the pixels. I want it so in fullscreen the aspect ratio is kept to the 256x144 ratio.
How about resizing it to the next full integer scale above the current resolution and then drawing the surface centred?

It will cut off a little of the game along the edges but it would retain the 1:1 pixel ratio, whether that would be acceptable depends on your game.
 
Top