Windows Draw GUI offset by 1 pixel

Discussion in 'GameMaker Studio 2 Community Tech Support' started by Redspark, May 20, 2019.

  1. Redspark

    Redspark Member

    Joined:
    Jul 17, 2016
    Posts:
    5
    Hi,

    Don't know if this is a bug or just something to do with the resolution scaling that I'm not understanding. However, when I create a room with a size and viewport of 1280x720 and turn on full screen (1366x768) through window_set_fullscreen(true) then I find that the GUI layer is offset by 1 pixel. So if I draw in the draw_gui event, coordinates 0,0 are at 1,0 in the normal draw event. Is this a bug or am I misunderstanding how this should be working? Thanks.
     
  2. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    This is my theory: 1280x720 and 1266x768 do not share the exact same aspect ratio. So when the viewport is automatically drawn to the screen, it will be scaled and centred. Because the aspect ratios of the viewport and are almost identical, the viewport will be drawn with a minimal x-offset of one pixel to make it centered.

    You can handle the drawing of the viewport (application surface) manually also, giving you full control. I have set up my screen draw system to use the full resolution of any monitor and then draw the applicaction surface manually at the correct position and size, with either pixel perfect scaling or max possible scale to fit either the width or height of the screen.
     
  3. nacho_chicken

    nacho_chicken Member

    Joined:
    Jun 21, 2016
    Posts:
    375
    You're correct. 1280x720 is 16:9 and 1366x768 is 683:384.
     
    Mick likes this.
  4. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    Yep, my theory starts at the second sentence to be more clear. :)
     
  5. Redspark

    Redspark Member

    Joined:
    Jul 17, 2016
    Posts:
    5
    Thanks. I suspected it was something like that. Are there any recommended tutorials on handling resolution scaling? I read the blog post by Mike back in 2014. Is that still the best way to deal with it? Thanks.
     

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