• 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 Problem with alpha blending and surfaces

A

AlexMdle

Guest
My game currently has application_surface_draw_enable set to false and I'm manually drawing the surface onto the screen. This works perfectly fine, however seems to clash with alphablending.

jumble.png

Code below is supposed to draw a red circle with the 0 alpha circle on top of it. Instead, a sort of a vacuum bubble is drawn, seemingly ignoring any draw code before it, but also not cleaning the values of any draw code after it - the jumble in the picture is the result of the player character moving around in that bubble.

It draws fine when application_surface_draw_enable draws by default - exception being that sprite_create_from_surface also fails to account for alpha blend(though that might be unrelated).

Code:
draw_circle_color(x,y,80,c_red,c_red,false);
gpu_set_blendenable(false);
gpu_set_colorwriteenable(false, false, false, true);

draw_set_alpha(0);
draw_circle(x,y,80,false);
draw_set_alpha(1);

gpu_set_colorwriteenable(true, true, true, true);
gpu_set_blendenable(true);
Anyone know what the problem might be?

Edit: I have managed to seemingly fix it by prefacing all the surface drawing with
Code:
gpu_set_blendmode_ext(bm_one, bm_inv_src_alpha);
gpu_set_blendenable(false);
It's not ideal but gets the job done. Im not sure if the topic needs to stay up, but I hope it helps anyone with the same problem.
 
Last edited by a moderator:

Bart

WiseBart
If you draw the application surface manually, you have to disable alpha blending before drawing it.
It's not mentioned in the manual, but there's a related issue in the bugtracker on this: 30191
It seems to be expected behavior.
 
A

AlexMdle

Guest
Really wish that was at least documented, it's definitely not expected knowledge. Thanks for sharing!
 
Top