Scale line-width to match zoom.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
} );
|
||||
|
||||
|
||||
@@ -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; } }
|
||||
|
||||
@@ -135,6 +135,12 @@ namespace OpenRA.Renderer.Cg
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetLineWidth( float width )
|
||||
{
|
||||
Gl.glLineWidth(width);
|
||||
ErrorHandler.CheckGlError();
|
||||
}
|
||||
|
||||
public IVertexBuffer<Vertex> CreateVertexBuffer( int size ) { return new VertexBuffer<Vertex>( size ); }
|
||||
public ITexture CreateTexture() { return new Texture(); }
|
||||
public ITexture CreateTexture( Bitmap bitmap ) { return new Texture( bitmap ); }
|
||||
|
||||
@@ -115,6 +115,12 @@ namespace OpenRA.Renderer.Glsl
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetLineWidth( float width )
|
||||
{
|
||||
Gl.glLineWidth(width);
|
||||
ErrorHandler.CheckGlError();
|
||||
}
|
||||
|
||||
public IVertexBuffer<Vertex> CreateVertexBuffer( int size ) { return new VertexBuffer<Vertex>( size ); }
|
||||
public ITexture CreateTexture() { return new Texture(); }
|
||||
public ITexture CreateTexture( Bitmap bitmap ) { return new Texture( bitmap ); }
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace OpenRA.Renderer.Null
|
||||
}
|
||||
|
||||
public void DrawPrimitives(PrimitiveType pt, int firstVertex, int numVertices) { }
|
||||
public void SetLineWidth( float width ) { }
|
||||
|
||||
public IVertexBuffer<Vertex> CreateVertexBuffer(int size) { return new NullVertexBuffer<Vertex>(); }
|
||||
public ITexture CreateTexture() { return new NullTexture(); }
|
||||
|
||||
Reference in New Issue
Block a user