diff --git a/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs b/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs index a405c9f1ce..a03041e12b 100755 --- a/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs +++ b/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs @@ -48,6 +48,7 @@ namespace OpenRA.FileFormats.Graphics void DrawPrimitives( PrimitiveType type, int firstVertex, int numVertices ); + void SetLineWidth( float width ); void EnableScissor( int left, int top, int width, int height ); void DisableScissor(); } diff --git a/OpenRA.Game/Graphics/LineRenderer.cs b/OpenRA.Game/Graphics/LineRenderer.cs index b9ded66d38..7425707537 100644 --- a/OpenRA.Game/Graphics/LineRenderer.cs +++ b/OpenRA.Game/Graphics/LineRenderer.cs @@ -15,6 +15,8 @@ namespace OpenRA.Graphics { public class LineRenderer : Renderer.IBatchRenderer { + public float LineWidth = 1f; + Renderer renderer; IShader shader; @@ -35,6 +37,7 @@ namespace OpenRA.Graphics { var vb = renderer.GetTempVertexBuffer(); vb.SetData( vertices, nv ); + renderer.SetLineWidth(LineWidth); renderer.DrawBatch( vb, 0, nv, PrimitiveType.LineList ); } ); diff --git a/OpenRA.Game/Graphics/Renderer.cs b/OpenRA.Game/Graphics/Renderer.cs index c415638bf8..441396364b 100644 --- a/OpenRA.Game/Graphics/Renderer.cs +++ b/OpenRA.Game/Graphics/Renderer.cs @@ -77,9 +77,11 @@ namespace OpenRA.Graphics { device.Clear(Color.Black); + WorldLineRenderer.LineWidth = zoom; float2 r1 = new float2(2f/Resolution.Width, -2f/Resolution.Height); float2 r2 = new float2(-1, 1); var zr1 = zoom*r1; + SetShaderParams( WorldSpriteShader, zr1, r2, scroll ); SetShaderParams( WorldLineShader, zr1, r2, scroll ); SetShaderParams( LineShader, r1, r2, scroll ); @@ -116,6 +118,11 @@ namespace OpenRA.Graphics CurrentBatchRenderer = null; } + public void SetLineWidth(float width) + { + device.SetLineWidth(width); + } + static IGraphicsDevice device; public static Size Resolution { get { return device.WindowSize; } } diff --git a/OpenRA.Renderer.Cg/GraphicsDevice.cs b/OpenRA.Renderer.Cg/GraphicsDevice.cs index b5b99b41a5..d377998d02 100755 --- a/OpenRA.Renderer.Cg/GraphicsDevice.cs +++ b/OpenRA.Renderer.Cg/GraphicsDevice.cs @@ -135,6 +135,12 @@ namespace OpenRA.Renderer.Cg throw new NotImplementedException(); } + public void SetLineWidth( float width ) + { + Gl.glLineWidth(width); + ErrorHandler.CheckGlError(); + } + public IVertexBuffer CreateVertexBuffer( int size ) { return new VertexBuffer( size ); } public ITexture CreateTexture() { return new Texture(); } public ITexture CreateTexture( Bitmap bitmap ) { return new Texture( bitmap ); } diff --git a/OpenRA.Renderer.Gl/GraphicsDevice.cs b/OpenRA.Renderer.Gl/GraphicsDevice.cs index 3e592e531d..c95780e4f5 100755 --- a/OpenRA.Renderer.Gl/GraphicsDevice.cs +++ b/OpenRA.Renderer.Gl/GraphicsDevice.cs @@ -115,6 +115,12 @@ namespace OpenRA.Renderer.Glsl throw new NotImplementedException(); } + public void SetLineWidth( float width ) + { + Gl.glLineWidth(width); + ErrorHandler.CheckGlError(); + } + public IVertexBuffer CreateVertexBuffer( int size ) { return new VertexBuffer( size ); } public ITexture CreateTexture() { return new Texture(); } public ITexture CreateTexture( Bitmap bitmap ) { return new Texture( bitmap ); } diff --git a/OpenRA.Renderer.Null/NullGraphicsDevice.cs b/OpenRA.Renderer.Null/NullGraphicsDevice.cs index 27453d55ca..d85e0828c8 100644 --- a/OpenRA.Renderer.Null/NullGraphicsDevice.cs +++ b/OpenRA.Renderer.Null/NullGraphicsDevice.cs @@ -48,6 +48,7 @@ namespace OpenRA.Renderer.Null } public void DrawPrimitives(PrimitiveType pt, int firstVertex, int numVertices) { } + public void SetLineWidth( float width ) { } public IVertexBuffer CreateVertexBuffer(int size) { return new NullVertexBuffer(); } public ITexture CreateTexture() { return new NullTexture(); }