• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Windows [SOLVED] Bug on copying a surface: particles causing holes

matharoo

manualman
GameMaker Dev.
Hey there.

I'm coding a pause system and for that I need to save the application_surface (at the moment it is paused) to another surface.

When I do that though, particles drawn on the application surface cause holes in my surface.

Example
Normal game (you can see the smoke particles):
upload_2019-1-16_22-49-38.png

Paused game (you can see the hole in the surface):
upload_2019-1-16_22-49-52.png

Code

Here's the code that saves the application surface to my own:
Code:
//Surface
pauseSurf = surface_create(surface_get_width(application_surface), surface_get_height(application_surface));

surface_copy(pauseSurf, 0, 0, application_surface);
Drawing the surface onto it instead of using surface_copy() has the same effect.

Also, ignore the blur shader, the bug exists even when the surface is directly drawn without any shaders.

Any ideas?

Thanks!
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
This is probably because of the alpha blending with the particles and the app surface. By default, GMS2 will draw the app surface with alpha blending disabled, but when you copy it and draw it yourself this is no longer the case. The solution will either be to not use surface copy, but rather draw the app surface to the new surface without any alpha blending, or to draw the copied surface to the screen without any alpha blending. See the function gpu_set_blendenable().
 

matharoo

manualman
GameMaker Dev.
This is probably because of the alpha blending with the particles and the app surface. By default, GMS2 will draw the app surface with alpha blending disabled, but when you copy it and draw it yourself this is no longer the case. The solution will either be to not use surface copy, but rather draw the app surface to the new surface without any alpha blending, or to draw the copied surface to the screen without any alpha blending. See the function gpu_set_blendenable().
Thanks Nocturne, that fixes it. Doing only one of those things didn't fix it, but doing both did (disabling alpha blending while copying and while drawing the copied surface).
 
Top