Nullable fixes, use Texture2d resource for rendering directly.

This commit is contained in:
2024-01-21 17:34:49 +01:00
parent cfbf46860d
commit 5f4e32e2e0
10 changed files with 105 additions and 74 deletions

View File

@@ -6,20 +6,18 @@ namespace DaggerFramework.SceneGraph
{
public class Sprite2d : Drawable2d
{
public Texture2d Texture { get => _texture; set => _texture = value; }
public Texture2d Texture { get => _texture ?? Texture2d.Empty; set => _texture = value; }
protected override void OnStart()
{
var renderer = Layer.Scene.Renderer;
_texId = renderer.LoadTexture(_texture);
}
public override void OnDraw(Renderer renderer)
{
renderer.DrawTexture(_texId, Color.White);
renderer.DrawTexture(_texture!, Color.White);
}
private Texture2d _texture;
private int _texId;
private Texture2d? _texture;
}
}