Get size of "scaled" view / How to achieve pixel perfect scaling with free window scaling

Fluury

Member
Heya.

Following Issue: Similar to Nuclear Throne I'd like to allow the player to freely resize the window to their liking while keeping the area within the window the same - this means we get Black Bars. These are fine, what however isn't fine is the game's sprites getting all crusty.

Screenshots:

nocrust.png
To see is the default setup alongside a couple of handy values thanks to Pixelated Pope's Script. As you can see when looking at the player, the amount of crust is very minimal.

fullcrust.png
This is the game after maximizing the window. Take a look at the player sprite now and notice the black bars to the left and right, what we are dealing with here is crust. My goal is to get rid of this crust.

The same crust appears if you scale the window even to perfect scales such as 1980x1080.

The answer I ended up with (after the help of some other people) is that it boils down to the Application Surface not rescaling - makes sense. However the information I now need is the width and height of the area within the black bars, and I for the love of god cannot seem to get to them. Wanting to test 1980x1080, I set the application surface size to 1980x1080, went fullscreen and voila, no crust to be seen. So clearly the goal is to set the application surface to scale with the area inside the black bars, the "scaled view".

For the people thinking it max be the viewport, I must disappoint you:
viewport experiment.png
This is the screen after trying to scale it to the viewport, thinking that the area within the black bars is the viewport size. Strangely enough these values ended up being the default viewport values from the room editor, which I had not touched. Viewports and all that jazz are all enabled manually. The viewport values are gained by doing view_get_hport(0).

For the sake of completion, here is all the relevant scaling code I am doing:
GML:
global.view_width = 320;
global.view_height = 180;

global.window_scale = 5;

cam = view_camera[0];

window_set_size(global.view_width*global.window_scale,global.view_height*global.window_scale);
alarm[0] = 1;     //Centers window

surface_resize(application_surface,global.view_width*global.window_scale,global.view_height*global.window_scale);

camera_set_view_size(cam,global.view_width*global.window_scale,global.view_height*global.window_scale);

global.view_width_half = camera_get_view_width(cam)/2;
global.view_height_half = camera_get_view_height(cam)/2;

display_set_gui_size(global.view_width*global.window_scale,global.view_height*global.window_scale);
I have been wrestling with this issue for... well, the entire saturday, so I would heavily appreciate if anyone could help me out with this issue as I am a huge fan of how Nuclear Throne allows their players to scale the window however they want to, while keeping the sprites looking crisp.
Thanks for your attention.
 

Fluury

Member
A recent idea that came up in the reddit thread I made for this issue was calculating the size of the black bars, however the means of doing so remain a mystery to me.
 

Fluury

Member
Well, for anyone else looking for this thread potentially in the future:

The solution lies in application_get_position! The example code in the documentation even tells you how to get the absolute width/height.

Solved!
 
Top