Legacy GM Surface leak error [solved]

alexde5th

Member
Figured out the issue: There was an improper balance of alpha drawing.
For the longest time, the basic surface I've been drawing too worked without a hitch. Then suddenly, after I changed some completely unrelated code to the surface code, it breaks.
It only properly displays when a specific instance is drawing to the screen.
The two instances are the shading system and the player controller.
The depth of the shading system is -20, and the player controller is -30, but makes no difference if it's higher or lower than the shading system.

Without:

With:


[edit]
The code:
[Draw event]
Code:
if (global.EnableLighting = 1)
    {
    if (surface_exists(global.AmbLightShadow))
        {
        draw_set_blend_mode(bm_subtract);
        draw_surface(global.AmbLightShadow,view_xview,view_yview);
        draw_set_blend_mode(bm_normal);
        }
    }
[Step event]
Code:
if (global.EnableLighting = 1)
{
if (view_wview > 0 and view_hview > 0)
    {
    if (!surface_exists(global.AmbLightShadow))
        {
        draw_set_alpha(1);
        global.AmbLightShadow = surface_create(view_wview,view_hview);
        surface_set_target(global.AmbLightShadow);
        draw_set_color(global.AmbLightColour);
        draw_rectangle(0,0,view_wview,view_hview,false);
        surface_reset_target();
        }
        else
        {
        SURFX = surface_get_width(global.AmbLightShadow);
        SURFY = surface_get_height(global.AmbLightShadow);
        if (SURFX != view_wview and SURFY != view_hview){
            surface_resize(global.AmbLightShadow,view_wview,view_hview);
            }
        surface_set_target(global.AmbLightShadow);
        draw_set_color(global.AmbLightColour);
        draw_rectangle(0,0,view_wview,view_hview,false);
        surface_reset_target();
        }
    }
}
else if (global.EnableLighting = 0)
    {
    ///destruction of surface
    if (surface_exists(global.AmbLightShadow)) {
        surface_free(global.AmbLightShadow);
        }
    }
[update 2]
I found the issue: There was an improper balance of alpha drawing in the player controller.
 
Last edited:
Top