Allow SheetBuilder to generate 1/2/4 channel sheets.

This makes the SpriteFont RBGA sprite hack explicit,
and adds a DualIndexed option to be used by the voxel
renderer.
This commit is contained in:
Paul Chote
2013-05-06 20:48:09 +12:00
parent 28d4df355d
commit 4ebe547a05
4 changed files with 34 additions and 24 deletions

View File

@@ -31,8 +31,10 @@ namespace OpenRA.Graphics
glyphs = new Cache<Pair<char, Color>, GlyphInfo>(CreateGlyph,
Pair<char,Color>.EqualityComparer);
// setup a 1-channel SheetBuilder for our private use
if (builder == null) builder = new SheetBuilder(TextureChannel.Alpha);
// setup a SheetBuilder for our private use
// TODO: SheetBuilder state is leaked between mod switches
if (builder == null)
builder = new SheetBuilder(SheetType.BGRA);
PrecacheColor(Color.White);
PrecacheColor(Color.Red);
@@ -46,7 +48,7 @@ namespace OpenRA.Graphics
throw new InvalidOperationException();
}
public void DrawText (string text, float2 location, Color c)
public void DrawText(string text, float2 location, Color c)
{
location.Y += size; // baseline vs top
@@ -84,7 +86,7 @@ namespace OpenRA.Graphics
public int2 Measure(string text)
{
return new int2((int)text.Split( '\n' ).Max( s => s.Sum(a => glyphs[Pair.New(a, Color.White)].Advance)), text.Split('\n').Count()*size);
return new int2((int)text.Split('\n').Max(s => s.Sum(a => glyphs[Pair.New(a, Color.White)].Advance)), text.Split('\n').Count()*size);
}
Cache<Pair<char,Color>, GlyphInfo> glyphs;