Skip to main content
Extremely Specific

Gamemaker: Transparency issues when copying application surface to new surface

The Problem

In GameMaker, transparency acts differently on the application surface than it does on other surfaces. This poses a problem if you are drawing shadows or something with transparency in your game, and then you try to copy the application surface to another surface. You might find that your shadows make the new surface transparent.

The Solution

When you copy the application surface, clear it with a solid black first, then use gpu_set_colorwriteenable to prevent the application surface's alpha values from being transferred.

surface_set_target(surf);
draw_clear_alpha(c_black,1);
surface_reset_target();

gpu_set_colorwriteenable(true,true,true,false);
surface_copy(surf,0,0,application_surface);
gpu_set_colorwriteenable(true,true,true,true);