Legacy GM Solved: Can't Copy the Application Surface

J

Jon Perry

Guest
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?
 

obscene

Member
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.
 
J

Jon Perry

Guest
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.
 
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?
 

Vishnya

Member
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.
Enable debug mode and watch what surfaces contains
 

TheouAegis

Member
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.
 
J

Jon Perry

Guest
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.
 
Top