Change folder structure, add solution to the root.

This commit is contained in:
2023-06-18 17:19:03 +02:00
parent d5f5fb5614
commit 15747d7e9b
51 changed files with 33 additions and 6 deletions

View File

@@ -0,0 +1,150 @@
using System.Numerics;
namespace DaggerFramework.Rendering
{
/// <summary>
/// An abstract class representing the graphics renderer.
/// </summary>
public abstract class Renderer
{
// INIT
/// <summary>
/// Creates the renderer window and initializes internal resources.
/// </summary>
/// <param name="windowSettings">Settings for the rendering window.</param>
/// <param name="renderSettings">Rendering settings.</param>
public abstract void CreateAndInitialize(WindowSettings windowSettings, RendererSettings renderSettings);
/// <summary>
/// Initializes internal resources. Should be called before other methods.
/// </summary>
/// <param name="settings">Rendering settings.</param>
public abstract void Initialize(RendererSettings settings);
// UTIL
/// <summary>
/// Indicates if the renderer will render the next frame.
/// </summary>
public abstract bool ShouldRun { get; }
// WINDOW
/// <summary>
/// The size of the render window.
/// </summary>
public abstract Vector2 WindowSize { get; }
/// <summary>
/// Creates the window with a given title and size.
/// </summary>
/// <param name="title">Title of the window.</param>
/// <param name="size">Vector2 representing size.</param>
public abstract void CreateWindow(string title, Vector2 size);
public void CreateWindow(WindowSettings windowSettings)
{
CreateWindow(windowSettings.Title, windowSettings.Size);
}
// TODO: use properties for these.
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 Shutdown();
// DRAWING
/// <summary>
/// Prepares the renderer for drawing the next frame.
/// </summary>
public abstract void BeginFrame();
/// <summary>
/// Ends rendering of the frame.
/// </summary>
public abstract void EndFrame();
/// <summary>
/// Clears the render canvas and sets a background color.
/// </summary>
/// <param name="color">Background color.</param>
public abstract void ClearBackground(Color color);
public abstract double GetFrameTime();
/// <summary>
/// Loads the texture onto the GPU for later use in DrawTexture or other Texture related methods.
/// </summary>
/// <param name="texture">Texture to load.</param>
/// <returns>A texture handler on the GPU.</returns>
public abstract int LoadTexture(Texture2d texture);
/// <summary>
/// Sets transforms for the next draw operation.
/// </summary>
/// <param name="position">Global transform position.</param>
/// <param name="rotation">Rotation.</param>
public abstract void SetTransform(Vector2 position, float rotation = 0.0f);
/// <summary>
/// Sets the transform for the next draw operation.
/// </summary>
/// <param name="transform">Transform matrix.</param>
public abstract void SetTransform(Matrix4x4 transform);
/// <summary>
/// Draws a filled circle.
/// </summary>
/// <param name="radius">Radius of a circle.</param>
/// <param name="color">Fill color.</param>
public abstract void DrawCircle(float radius, Color color);
/// <summary>
/// Draws a filled rectangle.
/// </summary>
/// <param name="size">Rectangle size.</param>
/// <param name="color">Fill color.</param>
public abstract void DrawRectangle(Vector2 size, Color color);
/// <summary>
/// Draws a debug text with a default font.
/// </summary>
/// <param name="position"></param>
/// <param name="text"></param>
/// <param name="fontSize"></param>
/// <param name="color"></param>
public abstract void DrawDebugText(string text, int fontSize, Color color);
/// <summary>
/// Draws text using a signed distance field font atlas.
/// </summary>
/// <param name="text">Text to draw.</param>
/// <param name="fontSize">Size of the font.</param>
/// <param name="color">Color of the text.</param>
public abstract void DrawSdfText(string text, int fontSize, Color color);
/// <summary>
/// Draws the texture.
/// </summary>
/// <param name="id">Texture handle.</param>
/// <param name="tint">Texture tint.</param>
public abstract void DrawTexture(int id, Color tint);
}
public enum Msaa
{
None,
Msaa2x,
Msaa4x,
Msaa8x
}
public struct RendererSettings
{
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;
}
}
}