Windows How does depth work in <draw> [Solved]

Discussion in 'Programming' started by maru_th_undrtkr, Jul 10, 2019.

  1. maru_th_undrtkr

    maru_th_undrtkr Member

    Joined:
    Jan 23, 2018
    Posts:
    42
    I tried

    depth=0;
    draw_surface(sur_Foreground,cam_x,cam_y);

    depth=1;
    draw_surface(sur_background,cam_x,cam_y);

    but only the last depth gets excepted
    is there any way to draw the first surface over everything and the second under, depth only lets me do one per object. or is that just a limitation i need to work around, I can create another object just for it, but I figure I might be missing something.

    -_-
    im sorry i need sleep this is prob the answer
    draw_surface_part_ext
    wait no what, ...
     
  2. marasovec

    marasovec Member

    Joined:
    Sep 15, 2016
    Posts:
    288
    You changed the depth but the depth gets set in the next step not in the current one. So even if you set the depth to 0 and then to 1 it will take only the last one set (so 1).
    Draw the background first and then the foreground so the foreground will be drawn on top of the background
    Code:
    draw_surface(sur_background,cam_x,cam_y);
    draw_surface(sur_Foreground,cam_x,cam_y);
    
     
  3. IndianaBones

    IndianaBones Member

    Joined:
    Jul 5, 2016
    Posts:
    2,107
    Just to add to that, the documentation for depth specifically says:

    So best to do changing of depth in your (for example) Step events if you want to guarantee it taking effect during that frame.
     
    Bentley likes this.
  4. maru_th_undrtkr

    maru_th_undrtkr Member

    Joined:
    Jan 23, 2018
    Posts:
    42
    Thanks for the replies, very helpful info. This might not be optimal, but in case it helps anyone, I created a different object with a different depth and drew the surface from there. It works perfectly, despite this object literally do that one thing.
     
  5. Annoyed Grunt

    Annoyed Grunt Member

    Joined:
    Jun 20, 2016
    Posts:
    110
    You can also utilize the Draw Begin and Draw End events instead of creating a different object :)
    If you have two objects A and B where B is under A, stuff placed in A's Draw End event will still draw over B (but not over stuff drawn in B's own Draw End Event)

    Basically, the three Draw Events (Begin, Draw, and End) are three separate layers. Depth factors between stuff drawn in the same layer, but the three layers are drawn one over the other.
     

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