text rendering

This commit is contained in:
Chris Forbes
2009-10-29 21:45:29 +13:00
parent c3f8019ab4
commit 9d543db7fc
3 changed files with 23 additions and 4 deletions

View File

@@ -13,6 +13,9 @@ namespace OpenRa.Game.Graphics
public Shader SpriteShader { get; private set; } /* note: shared shader params */
public Shader LineShader { get; private set; }
readonly SpriteHelper sh;
readonly FontHelper fhDebug;
public void BuildPalette(Map map)
{
palettes = Util.MakeArray(7, i => new HardwarePalette(this, map, i).Texture);
@@ -33,6 +36,9 @@ namespace OpenRa.Game.Graphics
SpriteShader.Quality = ShaderQuality.Low;
LineShader = new Shader(device, FileSystem.Open("line.fx"));
LineShader.Quality = ShaderQuality.High;
sh = new SpriteHelper(device );
fhDebug = new FontHelper(device, "Tahoma", 10, false );
}
public GraphicsDevice Device { get { return device; } }
@@ -83,5 +89,12 @@ namespace OpenRa.Game.Graphics
device.DrawIndexedPrimitives(type,
vertexPool, numPrimitives);
}
public void DrawText(string text, int2 pos, Color c)
{
sh.Begin();
fhDebug.Draw(sh, text, pos.X, pos.Y, c.ToArgb());
sh.End();
}
}
}