Automatically flush line renderer when changing width.
This commit is contained in:
@@ -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) {}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user