• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Lightning System doesn't work since runtime 2.2.x

W

WinuX

Guest
Hello everyone

My lightning system seems to stop working when I'm above runtime 2.1.5.

Code:
///////////////////// CREATE ///////////////////

lightsurface = noone;
darknesscol[0] = c_black;
darknesscol[1] = c_black;
darknesscol[2] = c_black;
darknesscol[3] = c_black;


///////////////////// STEP /////////////////////

if (!surface_exists(lightsurface)) {lightsurface = surface_create(room_width, room_height);}



///////////////////// DRAW /////////////////////

if (surface_exists(lightsurface))
{
    surface_set_target(lightsurface);
    draw_rectangle_colour(0,0,room_width,room_height,darknesscol[0], darknesscol[1], darknesscol[2], darknesscol[3], false);
    with (obj_prnt_li)
    {
        if (on)
        {
            gpu_set_blendmode(bm_add);
            draw_sprite_ext(sprite,subimg,x,y,xscale,yscale,rotation,col[0],alpha);
            gpu_set_blendmode(bm_normal);  
        }
    }
    surface_reset_target();
    gpu_set_blendmode_ext(bm_dest_color,bm_zero);
    draw_surface_ext(lightsurface,0,0,1,1,0,c_white,1);
    gpu_set_blendmode(bm_normal);
}
Screenshot when I'm on runtime 2.1.5


Screenshot when I'm on runtime 2.2.1



Thanks for the coming answers :D
 
W

WinuX

Guest
I'm not sure if this applies to your issue, but GMS 2.2 made some changes to the way surfaces are used.
This article goes into more detail:
https://www.yoyogames.com/blog/493/using-surfaces

EDIT: What happens if you move that line of code from the step event to the top of the Draw event?
The blog was for 2.2.1, but it also does not work in 2.2.0, so I guess that isn't the Problem.

When I move the code from the step event to the draw event the problem still persists.
 

chamaeleon

Member
The blog was for 2.2.1, but it also does not work in 2.2.0, so I guess that isn't the Problem.

When I move the code from the step event to the draw event the problem still persists.
Out of curiosity, how large is your room, since you use the room size to create the surface, rather than something that relates more to the window or view size (unless they're the same more or less)? Any chance you are pushing the limits of available graphics memory? If you move the surface create code into the draw code, have you verified that you get back a valid surface from the call, so that your code creating the lighting effect actually executes?
 
W

WinuX

Guest
Out of curiosity, how large is your room, since you use the room size to create the surface, rather than something that relates more to the window or view size (unless they're the same more or less)? Any chance you are pushing the limits of available graphics memory? If you move the surface create code into the draw code, have you verified that you get back a valid surface from the call, so that your code creating the lighting effect actually executes?
The room is actually really big I don't have the size in my head, but it something like 4000 x 2000.

But it also happens in smaller rooms (480x270) so I guess that isn't the problem

I will check for the surface ID as soon as I get a chance to.
 
W

WinuX

Guest
Out of curiosity, how large is your room, since you use the room size to create the surface, rather than something that relates more to the window or view size (unless they're the same more or less)? Any chance you are pushing the limits of available graphics memory? If you move the surface create code into the draw code, have you verified that you get back a valid surface from the call, so that your code creating the lighting effect actually executes?
It returns a valid surface, I also tested if it goes into the if (surface_exists(lightsurface)) and it does.
 
Top