• 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!

How to scale and draw application surface manually?

G

Golden Gremlin

Guest
I am trying to scale and manually draw my application surface to my fullscreen game window. Ultimately, I am doing this so that I can guarantee I am scaling by an integer when in fullscreen mode, to prevent pixel distortion.

As a test, I am just trying to scale my application_surface by 2 and draw it at the origin of the fullscreen window.

This is what I have in my resolution_manager's creation event:

Code:
application_surface_draw_enable(false);

scale = 2;

// get monitor size & aspect ratio
display_width = display_get_width();
display_height = display_get_height();
display_aspect_ratio = display_width/display_height;

// specify native resolution
ideal_width = 427
ideal_height = 240

// set gui size
display_set_gui_size(ideal_width, ideal_height);

// set view size for all rooms
for (var i = 0; i <= room_last; i++)
{
    if room_exists(i)
    {
        room_set_viewport(i, 0, true, 0, 0, ideal_width, ideal_height);
        room_set_view_enabled(i, true);
        room_set_camera(i, 0, 0);
    }
}

// resize application surface
surface_resize(application_surface, ideal_width * scale, ideal_height * scale);
And this is what I have in the post-draw event:

Code:
draw_surface(application_surface, 0, 0);
The result is not what I expected. Rather than scaling and stretching the application surface, what is drawn is just a wider view of my level. It seems like the view got scaled by 2 as well as the application window.

This is what it looks like:



This is what I want:



How can I fix this so that my application surface scales by 2 in the intended manner?
 

TheouAegis

Member
Don't resize the surface, draw it scaled up. Everything in the game should be drawn at 1:1 scale to the surface, then the surface should be drawn scaled. If you resize the surface at the beginning, you just doubled the canvas size, not the scale at which everything is drawn.
 
G

Golden Gremlin

Guest
Don't resize the surface, draw it scaled up. Everything in the game should be drawn at 1:1 scale to the surface, then the surface should be drawn scaled. If you resize the surface at the beginning, you just doubled the canvas size, not the scale at which everything is drawn.
This makes a lot of sense and indeed it works. Thanks!

I was trying to extend the method used by Pixelated Pope in his Resolution Manager Tutorial. When doing 2x and 3x windowed versions of the game, he actually resizes the application surface to x2 and x3, in addition to the window. I wonder why it works in that tutorial, but not here...
 
G

Golden Gremlin

Guest
@TheouAegis, I believe the tutorial was in GameMaker 1, before the introduction of views. So maybe now that views exist, it doesn't work exactly the same. In any event, thanks for the help. It's working now using your method.
 
Top