1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

How to scale and draw application surface manually?

Discussion in 'Programming' started by Golden Gremlin, Dec 1, 2019.

  1. Golden Gremlin

    Golden Gremlin Member

    Joined:
    Nov 28, 2019
    Posts:
    3
    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:

    [​IMG]

    This is what I want:

    [​IMG]

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

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,136
    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.
     
    Golden Gremlin likes this.
  3. Golden Gremlin

    Golden Gremlin Member

    Joined:
    Nov 28, 2019
    Posts:
    3
    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...
     
  4. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,136
    Not sure, I haven't followed his tut. Did he use views/cameras and you didn't.
     
  5. Golden Gremlin

    Golden Gremlin Member

    Joined:
    Nov 28, 2019
    Posts:
    3
    @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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice