From 626b83ba12d1bd1451e8463ac7126a538ce5d019 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 22 Jul 2011 22:52:09 +1200 Subject: [PATCH] Fix lines not being centered in the middle of a pixel --- OpenRA.Game/Graphics/LineRenderer.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenRA.Game/Graphics/LineRenderer.cs b/OpenRA.Game/Graphics/LineRenderer.cs index 7425707537..bc0c3f1431 100644 --- a/OpenRA.Game/Graphics/LineRenderer.cs +++ b/OpenRA.Game/Graphics/LineRenderer.cs @@ -16,6 +16,7 @@ namespace OpenRA.Graphics public class LineRenderer : Renderer.IBatchRenderer { public float LineWidth = 1f; + static float2 offset = new float2(0.5f,0.5f); Renderer renderer; IShader shader; @@ -62,11 +63,11 @@ namespace OpenRA.Graphics if( nv + 2 > Renderer.TempBufferSize ) Flush(); - vertices[ nv++ ] = new Vertex( start, + vertices[ nv++ ] = new Vertex( start + offset, new float2( startColor.R / 255.0f, startColor.G / 255.0f ), new float2( startColor.B / 255.0f, startColor.A / 255.0f ) ); - vertices[ nv++ ] = new Vertex( end, + vertices[ nv++ ] = new Vertex( end + offset, new float2( endColor.R / 255.0f, endColor.G / 255.0f ), new float2( endColor.B / 255.0f, endColor.A / 255.0f ) ); }