Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for blend modes with drawQuads, closes #2196 #2199

Merged
merged 10 commits into from
Dec 7, 2018
Merged
2 changes: 2 additions & 0 deletions flixel/FlxCamera.hx
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ class FlxCamera extends FlxBasic
&& _headTiles.colored == colored
&& _headTiles.hasColorOffsets == hasColorOffsets
&& _headTiles.blending == blendInt
&& _headTiles.blend == blend
&& _headTiles.antialiasing == smooth
&& _headTiles.shader == shader)
{
Expand All @@ -493,6 +494,7 @@ class FlxCamera extends FlxBasic
itemToReturn.colored = colored;
itemToReturn.hasColorOffsets = hasColorOffsets;
itemToReturn.blending = blendInt;
itemToReturn.blend = blend;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we also need to check blend earlier in this function (lines 468-474) to check if two draw items are the same?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

itemToReturn.shader = shader;

itemToReturn.nextTyped = _headTiles;
Expand Down
1 change: 1 addition & 0 deletions flixel/graphics/tile/FlxDrawBaseItem.hx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class FlxDrawBaseItem<T>
public var colored:Bool = false;
public var hasColorOffsets:Bool = false;
public var blending:Int = 0;
public var blend:BlendMode;

public var type:FlxDrawItemType;

Expand Down
5 changes: 4 additions & 1 deletion flixel/graphics/tile/FlxDrawQuadsItem.hx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ class FlxDrawQuadsItem extends FlxDrawBaseItem<FlxDrawQuadsItem>

setParameterValue(shader.hasTransform, true);
setParameterValue(shader.hasColorTransform, colored || hasColorOffsets);


#if (openfl > "8.7.0")
camera.canvas.graphics.overrideBlendMode(blend);
JoeCreates marked this conversation as resolved.
Show resolved Hide resolved
#end
camera.canvas.graphics.beginShaderFill(shader);
camera.canvas.graphics.drawQuads(rects, null, transforms);
super.render(camera);
Expand Down