1. Hey! Guest! The 34th GMC Jam will take place between August 22nd, 12:00 UTC (Thursday noon) and August 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GM:S 1.4 Solved: Can't Copy the Application Surface

Discussion in 'Programming' started by Jon Perry, Mar 13, 2019.

  1. Jon Perry

    Jon Perry Member

    Joined:
    Mar 13, 2019
    Posts:
    4
    I am trying to copy the application surface to a new surface object, but every way I've tried this the object ends up completely empty of any image information.

    At the beginning of my project I have this code just to make sure the application surface is enabled:

    application_surface_enable(true);
    application_surface_draw_enable(true);​

    I am also creating a surface to copy to:

    surf = surface_create(384,216);
    Later in the draw end event I am trying to copy the application surface to my own surface:

    surface_copy(surf, 0, 0, application_surface);​

    Finally in order to test if this is successful I am saving the surface to a file. (This is triggered off of a key-press)

    surface_save(surf, "test.png");
    Unfortunately, when I go look at the file, it is the right dimensions but completely empty of information. My game has lots of background tiles and objects on the screen that should be appearing but are not. It's as if the application_surface is not being written to at all.

    What step am I missing?
     
  2. obscene

    obscene Member

    Joined:
    Jun 21, 2016
    Posts:
    2,402
    I've done something like this and it worked. But it matters when you make the copy. Make sure it's in the draw event after the stuff has already been drawn to it that you want to include, ie in an object with a lower depth than your other stuff.
     
  3. Jon Perry

    Jon Perry Member

    Joined:
    Mar 13, 2019
    Posts:
    4
    Those are definitely good things to check. Unfortunately I'm calling it in the Draw End event of an object with a really low depth number (only 5) so I don't think the timing of the call is the problem.
     
  4. IndianaBones

    IndianaBones Member

    Joined:
    Jul 5, 2016
    Posts:
    2,163
    You don't have multiple views enabled by any chance? Have you tried drawing the surface to screen to confirm that its the copying thats not working, rather than the saving to disk?
     
  5. Vishnya

    Vishnya Member

    Joined:
    Jul 6, 2016
    Posts:
    65
    Enable debug mode and watch what surfaces contains
     
  6. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,642
    Is your surface and the application surface the same size?

    Try creating the surface in the draw event if it doesn't exist. Just set the variable to -1 by default.
     
  7. Jon Perry

    Jon Perry Member

    Joined:
    Mar 13, 2019
    Posts:
    4
    Thanks for the ideas everyone.

    @Vishnya the debugger ended up helping me solve the problem. I am working on a group project and there was some legacy code I was not aware of that was causing things to be written to a different surface from the application surface.
     
    obscene 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