Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Glue + Tiled] - Fixed alpha rendering bug where additive alpha would…
…n't get reset when rendering a tile map.
  • Loading branch information
vchelaru committed Feb 15, 2019
1 parent 90d08e9 commit 68edb78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Expand Up @@ -924,7 +924,8 @@ public void Draw(Camera camera)
FlatRedBallServices.GraphicsOptions.TextureFilter = this.TextureFilter.Value;
}
TextureAddressMode oldTextureAddressMode;
Effect effectTouse = PrepareRenderingStates(camera, out oldTextureAddressMode);
FlatRedBall.Graphics.BlendOperation oldBlendOp;
Effect effectTouse = PrepareRenderingStates(camera, out oldTextureAddressMode, out oldBlendOp);

foreach (EffectPass pass in effectTouse.CurrentTechnique.Passes)
{
Expand All @@ -949,6 +950,8 @@ public void Draw(Camera camera)
}

Renderer.TextureAddressMode = oldTextureAddressMode;
FlatRedBall.Graphics.Renderer.BlendOperation = oldBlendOp;

if (ZBuffered)
{
FlatRedBallServices.GraphicsDevice.DepthStencilState = DepthStencilState.DepthRead;
Expand All @@ -960,12 +963,12 @@ public void Draw(Camera camera)
}
}

private Effect PrepareRenderingStates(Camera camera, out TextureAddressMode oldTextureAddressMode)
private Effect PrepareRenderingStates(Camera camera, out TextureAddressMode oldTextureAddressMode, out FlatRedBall.Graphics.BlendOperation oldBlendOperation)
{
// Set graphics states
FlatRedBallServices.GraphicsDevice.RasterizerState = RasterizerState.CullNone;

var oldBlendOp = FlatRedBall.Graphics.Renderer.BlendOperation;
oldBlendOperation = FlatRedBall.Graphics.Renderer.BlendOperation;

#if TILEMAPS_ALPHA_AND_COLOR
FlatRedBall.Graphics.Renderer.BlendOperation = BlendOperation.Regular;
Expand Down Expand Up @@ -1010,10 +1013,7 @@ private Effect PrepareRenderingStates(Camera camera, out TextureAddressMode oldT
// on non-power-of-two textures.
oldTextureAddressMode = Renderer.TextureAddressMode;
Renderer.TextureAddressMode = TextureAddressMode.Clamp;


FlatRedBall.Graphics.Renderer.BlendOperation = oldBlendOp;


return effectTouse;
}

Expand Down
4 changes: 3 additions & 1 deletion FRBDK/Glue/PlatformerPlugin/MainPlugin.cs
Expand Up @@ -50,7 +50,9 @@ public override Version Version
// 1.3.6 - New build with latest Glue to address any syntax changes to underlying libs
// 1.3.7 - Added default input for vertical movement (jumping through clouds)
// 1.3.8 - Removed "0" in top left corner caused by debug write
return new Version(1, 3, 8);
// 1.3.9 - Fixed blend operation setting on maps - if a previous sprite used add, then
// the layer was drawn with add
return new Version(1, 3, 9);
}
}

Expand Down

0 comments on commit 68edb78

Please sign in to comment.