Update TestGame, load fonts from memory.

This commit is contained in:
2024-01-21 00:25:23 +01:00
parent 3e5e010527
commit fb5033f9a7
7 changed files with 66 additions and 72 deletions

View File

@@ -6,7 +6,6 @@ namespace DaggerFramework.SceneGraph
public class Text2d : Drawable2d
{
public string Text { get => _text; set => _text = value; }
public int FontSize { get => _fontSize; set => _fontSize = value; }
public Color FontColor { get => _fontColor; set => _fontColor = value; }
public Font Font
{
@@ -17,26 +16,24 @@ namespace DaggerFramework.SceneGraph
}
}
public Text2d(Font font)
{
_font = font;
}
public override void OnDraw(Renderer renderer)
{
if (_isDirty)
{
_fontHandle = renderer.LoadFont(_font);
_isDirty = false;
}
if (_font == null)
{
renderer.DrawDebugText(_text, _fontSize, _fontColor);
renderer.DrawDebugText(_text, 20, _fontColor);
}
else
{
renderer.DrawText(_fontHandle, _text, _fontSize, _fontColor);
renderer.DrawText(_font, _text, _fontColor);
}
}
private string _text = string.Empty;
private int _fontSize = 16;
private Color _fontColor = Color.White;
private Font _font;
private int _fontHandle;