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

GM:S 1.4 View not quite filling window

Discussion in 'Programming' started by NeoShade, Jun 27, 2016.

  1. NeoShade

    NeoShade Member

    Joined:
    Jun 21, 2016
    Posts:
    166
    Hi guys,

    I'm playing around with window sizing and positioning and views as the first steps in a project, and I thought that I had the whole thing figured out, until I noticed that there's a thin black line at the bottom of my window where the view isn't quite filling it up.

    Here's my game process:


    Game starts by loading up a room called Rm_Setup.
    Rm_Setup is 240 wide and 160 tall.
    The creation code of Rm_Setup runs the following script:

    Code:
    /// initialise_window()
    {{
        // Define window aspect and scale
        global.window_width  = 240;
        global.window_height = 160;
        global.window_scale  = 4;
       
        // Calculate exact window dimensions
        var win_w = global.window_width  * global.window_scale;
        var win_h = global.window_height * global.window_scale;
       
        // Resize the window
        window_set_size(win_w, win_h);
       
        // Calculate screen dimensions
        var dsp_x_centre = display_get_width()/2;
        var dsp_y_centre = display_get_height()/2;
       
        // Relocate the window
        window_set_position(dsp_x_centre-win_w/2, dsp_y_centre-win_h/2)
    }}
    Next, the creation code in Rm_Setup sends the game to the next room.

    The next room, Rm_Test, is 640 wide and 480 high (though changing these values should not, and does not seem to affect the problem I'm having).
    The creation code of Rm_Test runs the following script (so far uncommented due to this problem I'm experiencing):

    Code:
    /// initialise_view()
    {{
        view_xview[0]   = 0;
        view_yview[0]   = 0;
       
        view_wview[0]   = global.window_width;
        view_hview[0]   = global.window_height;
       
        view_visible[0] = true;
        view_enabled    = true;
    }}

    Now, I'd have thought that by setting the size of the view to the exact size of the window (before any scaling takes place) that everything would just fit together nicely, but that doesn't seem to be the case. Regardless of the value I enter for global.window_scale, I still see a thin black bar across the bottom of the window.

    Any help on this one would be very much appreciated.
     
  2. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    7,046
    When dividing/multiplying always use floor() to make sure they are integer values. Also, throw in a few "show_debug_message" to the code to spit out what the actual values for each of those variables is at the start of each room... it's a VERY handy function and I have thousands of them littering my codebase for Skein!
     
  3. NeoShade

    NeoShade Member

    Joined:
    Jun 21, 2016
    Posts:
    166
    Thanks for the help Nocturne. Even after throwing in those couple of floor() functions and a bunch of debug messages to try to figure out where the discrepancy was, I couldn't find anything that looked out of the ordinary.

    I did end up fixing the problem though, by defining the view port. I was under the impression that if I got the window the right size then that window size would effectively be the view port, but apparently not. After setting the vie port to the same dimensions as the window, everything now works perfectly.
     
  4. lolslayer

    lolslayer Member

    Joined:
    Jun 23, 2016
    Posts:
    695
    Maybe you should reset the surface
     
  5. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    7,046
    Ah, yes! By default the window size is set to the size of the first view port in the game, but if you then change the window size, the view port isn't changed... so yeah, when resizing you need to fix the view, the port and the window. And as mentioned above you may want to change the app surface so it's not drawing 4 to 1 pixels (although that can be a bonus if you want smooth rotation - in Skein I have the surface at a higher res than the actual view), and you also may want to change the GUI size too...
     
  6. NeoShade

    NeoShade Member

    Joined:
    Jun 21, 2016
    Posts:
    166
    Right, yeah. I hadn't thought about actually resizing the application surface and GUI. I imagine that the GUI would have caught me up later down the track if you hadn't mentioned it, and I'd have been completely stumped as to why.

    I don't anticipate any rotations in the game, so in that case I assume it's best for the application surface to just be 1:1?
     
  7. RangerX

    RangerX Member

    Joined:
    Jun 20, 2016
    Posts:
    2,602
    Always better to be 1:1 so there never is any graphical deformation or loss.
     

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