Scale line-width to match zoom.

This commit is contained in:
Paul Chote
2011-07-22 21:13:14 +12:00
parent fc783ddf80
commit 6183621a72
6 changed files with 24 additions and 0 deletions

View File

@@ -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 );
} );

View File

@@ -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; } }