1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GM:S 1.4 [SOLVED] 3D FPS GUI Display Issue

Discussion in 'Programming' started by Anti-Icarus, Oct 26, 2017.

  1. Anti-Icarus

    Anti-Icarus Member

    Joined:
    Jun 21, 2016
    Posts:
    34
    In following along an old tutorial on how to create a 3D FPS in GM:S, I've encountered an issue in which the GUI is not displaying properly. Here is an image of an FPS when it was made in GameMaker 8:

    upload_2017-10-26_18-6-24.png

    And here is a screenshot of the FPS I made in GameMaker: Studio:

    GameMaker 3D display issue reduced size.png

    As you can see, the GUI in the former does not display as well as the latter did. I'm sure I need to add something else to the code in my gun object's draw event but it's hard to say what. At the time of this writing, that code looks like this:

    Code:
    d3d_set_projection_ortho(0, 0, 640, 480, 0);
    d3d_set_hidden(false);
    draw_sprite_ext(spr_shotgun, -1, 0, 224, 2, 2, 0, c_white, 1);
    draw_set_alpha(0.4);
    draw_healthbar(5, 460, 100, 475, health, c_black, c_red, c_lime, 0, true, true);
    draw_set_alpha(1);
    d3d_set_hidden(true);
    How can I get the GUI to display properly in 3D mode so that it won't come out all black?
     
  2. flyingsaucerinvasion

    flyingsaucerinvasion Member

    Joined:
    Jun 20, 2016
    Posts:
    2,250
    EDIT:

    I at first thought it had something to do with the draw colour, but then your 3d stuff should be black as well. Are you using any kind of lighting or fog?
     
  3. hamdrax24

    hamdrax24 Member

    Joined:
    Dec 30, 2016
    Posts:
    55
    use draw_gui
     
    lolslayer likes this.
  4. Anti-Icarus

    Anti-Icarus Member

    Joined:
    Jun 21, 2016
    Posts:
    34
    Yes, I'm using fog as per the original instructions by Mark Overmars. That said, I set up the fog in the Create event of my player object like this:

    Code:
    d3d_start();
    d3d_set_hidden(true);
    d3d_set_lighting(false);
    d3d_set_culling(false);
    d3d_set_fog(true, c_black, 10, 300);
    texture_set_interpolation(true);
     
  5. Anti-Icarus

    Anti-Icarus Member

    Joined:
    Jun 21, 2016
    Posts:
    34
    You mean within the code? I tried changing the Draw event to a Draw GUI event of my gun object. That didn't have any effect.
     
  6. hamdrax24

    hamdrax24 Member

    Joined:
    Dec 30, 2016
    Posts:
    55
    Try disabling fog and set drawcolor to white before you draw the sprites
     
  7. Anti-Icarus

    Anti-Icarus Member

    Joined:
    Jun 21, 2016
    Posts:
    34
    I disabled the fog and it appeared to do the trick. But where do I set the drawcolor to white before drawing the sprites? In the player object's Create event where the 3D is enabled in the first place?

    And how would you enable a fog effect without impacting the GUI?
     
  8. hamdrax24

    hamdrax24 Member

    Joined:
    Dec 30, 2016
    Posts:
    55
    You set draw color above the draw sprite command.
     
  9. hamdrax24

    hamdrax24 Member

    Joined:
    Dec 30, 2016
    Posts:
    55
    Be fore drawing the sprites disable fog. Then re-enable it when all the sprites have been drawn.
     
  10. Anti-Icarus

    Anti-Icarus Member

    Joined:
    Jun 21, 2016
    Posts:
    34
    Now which object would I need to be doing this in? The player object's Create event or the gun object's Draw event? The former initializes the 3D mode:

    Code:
    d3d_start();
    d3d_set_hidden(true);
    d3d_set_lighting(false);
    d3d_set_culling(false);
    d3d_set_fog(true, c_black, 10, 300);
    texture_set_interpolation(true);
    draw_set_alpha_test(true);
    draw_set_alpha_test_ref_value(40);
    The latter basically acts as what you might call the overlay for the player object's view in the 3D mode:

    Code:
    d3d_set_projection_ortho(0, 0, 640, 480, 0);
    d3d_set_hidden(false);
    draw_sprite_ext(spr_shotgun, -1, 0, 224, 2, 2, 0, c_white, 1);
    draw_set_alpha(0.4);
    draw_healthbar(5, 460, 100, 475, health, c_black, c_red, c_lime, 0, true, true);
    draw_set_alpha(1);
    d3d_set_hidden(true);
    If you are referring to the later, is the draw color set above draw_sprite_ext and enable the fog after draw_set_alpha or d3d_set_hidden?
     
  11. hamdrax24

    hamdrax24 Member

    Joined:
    Dec 30, 2016
    Posts:
    55
    Yes, draw color is set above draw_sprite_ext and enable fog after d3d_set_hidden
     
  12. hamdrax24

    hamdrax24 Member

    Joined:
    Dec 30, 2016
    Posts:
    55
    Note that you don't really have to set draw color since the default is white. But, including it allows for some simple effects, feel free to experiment.
     
  13. Anti-Icarus

    Anti-Icarus Member

    Joined:
    Jun 21, 2016
    Posts:
    34
    I just altered the gun object's Draw event so that the fog would be disabled before drawing the white color, effectively becoming this:

    Code:
    d3d_set_projection_ortho(0, 0, 640, 480, 0);
    d3d_set_hidden(false);
    d3d_set_fog(false, c_black, 10, 300);
    draw_set_color(c_white);
    draw_sprite_ext(spr_shotgun, -1, 0, 224, 2, 2, 0, c_white, 1);
    draw_set_alpha(0.4);
    draw_healthbar(5, 460, 100, 475, health, c_black, c_red, c_lime, 0, true, true);
    draw_set_alpha(1);
    d3d_set_hidden(true);
    d3d_set_fog(true, c_black, 10, 300);
    I
    So in other words, I left the fog setting as it is in the player object's Create event while managing to have the GUI elements visible without the fog covering them up like it has been doing up to now. I've had trouble understanding what you were trying to say, but it all worked out in the end. So thank you for your assistance! I'll be looking forward to doing a few experiments with this FPS in the future.
     

Share This Page