API renames, change ref renderer to in renderer in IDrawable, make Layer implement IDrawable.
This commit is contained in:
@@ -9,12 +9,19 @@ namespace DaggerFramework.Rendering
|
||||
public class GlRenderer : Renderer
|
||||
{
|
||||
public override Vector2 WindowSize => throw new NotImplementedException();
|
||||
public override bool ShouldRun => throw new NotImplementedException();
|
||||
|
||||
public override void Initialize(RendererSettings settings)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void CreateAndInitialize(WindowSettings windowSettings, RendererSettings renderSettings)
|
||||
{
|
||||
CreateWindow(windowSettings);
|
||||
Initialize(renderSettings);
|
||||
}
|
||||
|
||||
public override void BeginFrame()
|
||||
{
|
||||
_glfw.PollEvents();
|
||||
@@ -34,7 +41,7 @@ namespace DaggerFramework.Rendering
|
||||
}
|
||||
|
||||
public override void CreateWindow(string title, Vector2 size) => CreateWindowUnsafe(title, size);
|
||||
public override void CloseWindow()
|
||||
public override void Shutdown()
|
||||
{
|
||||
CloseWindowUnsafe();
|
||||
_glfw.Terminate();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -6,15 +6,24 @@ namespace DaggerFramework.Rendering
|
||||
public abstract class Renderer
|
||||
{
|
||||
// INIT
|
||||
public abstract void CreateAndInitialize(WindowSettings windowSettings, RendererSettings renderSettings);
|
||||
public abstract void Initialize(RendererSettings settings);
|
||||
|
||||
// UTIL
|
||||
public abstract bool ShouldRun { get; }
|
||||
|
||||
// WINDOW
|
||||
public abstract Vector2 WindowSize { get; }
|
||||
public abstract void CreateWindow(string title, Vector2 size);
|
||||
public void CreateWindow(WindowSettings windowSettings)
|
||||
{
|
||||
CreateWindow(windowSettings.Title, windowSettings.Size);
|
||||
}
|
||||
public abstract void SetWindowTitle(string title);
|
||||
public abstract void SetWindowVSync(bool value);
|
||||
public abstract void SetTargetFps(int fps);
|
||||
public abstract bool WindowShouldClose();
|
||||
public abstract void CloseWindow();
|
||||
public abstract void Shutdown();
|
||||
|
||||
// DRAWING
|
||||
public abstract void BeginFrame();
|
||||
@@ -43,5 +52,22 @@ namespace DaggerFramework.Rendering
|
||||
public Msaa Msaa;
|
||||
public bool UseVSync;
|
||||
public bool Fullscreen;
|
||||
|
||||
public static RendererSettings Default => new RendererSettings()
|
||||
{
|
||||
UseVSync = true,
|
||||
};
|
||||
}
|
||||
|
||||
public struct WindowSettings
|
||||
{
|
||||
public string Title;
|
||||
public Vector2 Size = new Vector2(640, 480);
|
||||
|
||||
public WindowSettings(string title, Vector2 size)
|
||||
{
|
||||
Title = title;
|
||||
Size = size;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user