GMS 2 Is there a GML function that does the same as "Clear Viewport Background" checkbox?

Discussion in 'Programming' started by pimeys, Jul 14, 2019 at 1:40 AM.

  1. pimeys

    pimeys Member

    Joined:
    Sunday
    Posts:
    6
    When you make a room, there is a checkbox "Clear Viewport Background".



    I'm creating my viewports manually with GML though, by having a persistent object which has an event for room start

    Code:
    view_enabled = true;
    view_visible[0] = true;
    
    and calling camera_set_view_pos() in each end step.

    Now this results in heavy 'smearing' effects though, like everything is drawn but the background is never cleared, if I don't have the checkbox mentioned above checked for each individual room. How can I make that work without having to click that annoying checkbox for every room?
     

    Attached Files:

  2. Lonewolff

    Lonewolff Member

    Joined:
    Jan 8, 2018
    Posts:
    1,088
    draw_clear() or draw_clear_alpha() :)
     
    pimeys likes this.
  3. pimeys

    pimeys Member

    Joined:
    Sunday
    Posts:
    6
    I tried that before, using draw_clear(c_black) in the pre-draw event but it didn't help there. Now I tried to use that line in the begin draw event, and there it seems to work.

    I don't really understand why it works in begin draw, but not pre-draw, but thank you for your help :)
     
    Lonewolff likes this.
  4. Lonewolff

    Lonewolff Member

    Joined:
    Jan 8, 2018
    Posts:
    1,088
    My guess is that 'pre-draw' is exactly that. So draw commands shouldn't really work there by rights.
     
    pimeys likes this.
  5. pimeys

    pimeys Member

    Joined:
    Sunday
    Posts:
    6
    I guess that makes sense. Thanks again! :)
     
    Lonewolff likes this.

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