GameMaker Drawing with alpha onto surfaces

H

HaydenL

Guest
So I'm trying to draw an inventory using a surface, so I can easily manipulate how the whole inventory is drawn, I'm doing this by drawing the green slots onto the surface first, then the items, and then the numbers. Some of the items' sprites being drawn on have transparent sections. While the color appears to be blending correctly, the transparent sprites and edges of text seem to be replacing the alpha value of the surface below instead of blending, as seen in the image attached.upload_2017-2-20_20-55-32.png

I've tried messing around with blend modes, but I can't seem to get any positive effects from that (although that was just me trying random combinations of blend modes). It seems like a pretty obvious issue but I can't find any threads on it, but I'm sure someone on here has a workaround. Any help would be appreciated.
 
P

PandaPenguin

Guest
I'm not sure what I'm looking for here?
the problem is the red squares blending over your inventory?
 
H

HaydenL

Guest
Okay I should have given a better description of the screenshot. The background is black with a pink square I put there to test the alpha issues. Because the bomb sprite is replacing the alpha value of the green draw slot beneath it, you can see the pink square in the background, but I want the inventory slots to be opaque.

If I change the background and draw the inventory at 2x scale, it looks like this:

upload_2017-2-20_22-45-52.png
the bombs fill color is a gray with an alpha value of 127, and you can see the background through it. Also if you look carefully at the numbers, you can see the background lines through some of them too.
I dont want to be able to see any background through the items
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Draw to the surface with alpha blending disabled... so, something like this:

Code:
surface_set_target(mysurface);
draw_set_colour_write_enable(true,true,true,false)
draw_sprite(sprite1)
draw_sprite(sprite2)
draw_set_colour_write_enable(true, true, true, true)
surface_reset_target();
(and read the blog post linked above too! ;) )
 
Top