diff --git a/OpenRA.Game/Graphics/BeamRenderable.cs b/OpenRA.Game/Graphics/BeamRenderable.cs index 83773bd443..17304644a5 100644 --- a/OpenRA.Game/Graphics/BeamRenderable.cs +++ b/OpenRA.Game/Graphics/BeamRenderable.cs @@ -49,20 +49,10 @@ namespace OpenRA.Graphics var src = wr.ScreenPosition(pos); var dest = wr.ScreenPosition(pos + length); - var lineWidth = wlr.LineWidth; - if (lineWidth != width) - { - wlr.Flush(); - wlr.LineWidth = width; - } - + var oldWidth = wlr.LineWidth; + wlr.LineWidth = width; wlr.DrawLine(src, dest, color, color); - - if (lineWidth != width) - { - wlr.Flush(); - wlr.LineWidth = lineWidth; - } + wlr.LineWidth = oldWidth; } public void RenderDebugGeometry(WorldRenderer wr) {} diff --git a/OpenRA.Game/Graphics/LineRenderer.cs b/OpenRA.Game/Graphics/LineRenderer.cs index c84c83486e..2e169ce62e 100644 --- a/OpenRA.Game/Graphics/LineRenderer.cs +++ b/OpenRA.Game/Graphics/LineRenderer.cs @@ -15,9 +15,8 @@ namespace OpenRA.Graphics { public class LineRenderer : Renderer.IBatchRenderer { - public float LineWidth = 1f; - static float2 offset = new float2(0.5f,0.5f); - + static float2 offset = new float2(0.5f, 0.5f); + float lineWidth = 1f; Renderer renderer; IShader shader; @@ -30,6 +29,19 @@ namespace OpenRA.Graphics this.shader = shader; } + + public float LineWidth + { + get { return lineWidth; } + set + { + if (LineWidth != value) + Flush(); + + lineWidth = value; + } + } + public void Flush() { if (nv > 0)