API renames, change ref renderer to in renderer in IDrawable, make Layer implement IDrawable.

This commit is contained in:
2023-06-15 22:39:34 +02:00
parent bf4fb6e1e3
commit 964b903500
18 changed files with 122 additions and 67 deletions

View File

@@ -7,16 +7,7 @@ namespace DaggerFramework.Rendering
public class RaylibRenderer : Renderer
{
public override Vector2 WindowSize => _windowSize;
public override void DrawCircle(float radius, System.Drawing.Color color)
{
Raylib.DrawCircle((int)_position.X, (int)_position.Y, radius, SystemColorToRaylibColor(color));
}
public override void SetTransform(Vector2 position, float rotation)
{
_position = position;
_rotation = rotation;
}
public override bool ShouldRun => !WindowShouldClose();
public override void CreateWindow(string title, Vector2 size)
{
@@ -45,7 +36,7 @@ namespace DaggerFramework.Rendering
return Raylib.WindowShouldClose();
}
public override void CloseWindow()
public override void Shutdown()
{
Raylib.CloseWindow();
}
@@ -70,9 +61,15 @@ namespace DaggerFramework.Rendering
return (double)Raylib.GetFrameTime();
}
private Raylib_cs.Color SystemColorToRaylibColor(System.Drawing.Color color)
public override void DrawCircle(float radius, System.Drawing.Color color)
{
return new Color { r = color.R, g = color.G, b = color.B, a = color.A };
Raylib.DrawCircle((int)_position.X, (int)_position.Y, radius, SystemColorToRaylibColor(color));
}
public override void SetTransform(Vector2 position, float rotation)
{
_position = position;
_rotation = rotation;
}
public override int LoadTexture(Texture2d texture)
@@ -125,7 +122,7 @@ namespace DaggerFramework.Rendering
public override void DrawSdfText(Vector2 position, string text, int fontSize, System.Drawing.Color color)
{
throw new NotImplementedException();
}
public override void Initialize(RendererSettings settings)
@@ -146,6 +143,17 @@ namespace DaggerFramework.Rendering
// TODO
public override void SetTransform(Matrix4x4 transform) { }
public override void CreateAndInitialize(WindowSettings windowSettings, RendererSettings renderSettings)
{
CreateWindow(windowSettings);
Initialize(renderSettings);
}
private Raylib_cs.Color SystemColorToRaylibColor(System.Drawing.Color color)
{
return new Color { r = color.R, g = color.G, b = color.B, a = color.A };
}
private List<Texture2D> _texturePool = new List<Texture2D>();
private Vector2 _position;
private float _rotation;