feat: modular HAL, Raylib backend, PBR shading, textures, 60 unit tests

- Replace hardcoded SDL3 windowing with IWindow/IInputState/Key abstractions
- Each render backend owns its window (Raylib GLFW, SDL3 for Vulkan)
- Raylib backend: DrawModelEx, custom GLSL shader with Fresnel, ACES
  tonemapping, gamma correction, hemisphere ambient
- Fix backface culling, mesh memory (NativeMemory.Alloc), texture loading
- Camera controllers use backend-agnostic Key enum (inverted yaw/strafe)
- Demo scene: 8 cubes, 7 spheres, torus knot OBJ with checker texture
- Extract ProceduralMesh + MeshMath from Program.cs to Engine.Graphics
- Vulkan backend deferred (compiles, untested, IWindow-compatible)
- 60 unit tests: ObjLoader, camera controllers, AiCommandProcessor,
  RenderBackendFactory, Timing, ProceduralMesh, MeshMath, Transform
- AGENTS.md for opencode integration
This commit is contained in:
emil28092005
2026-06-17 13:49:12 +03:00
parent 61f8c7065e
commit fb6e26a268
62 changed files with 22259 additions and 395 deletions
@@ -0,0 +1,36 @@
using Engine.Core;
namespace Engine.Graphics;
/// <summary>
/// Factory for creating concrete graphics backends by name.
/// Backends register themselves so the app only depends on the HAL interfaces.
/// Each backend creates and owns its own window.
/// </summary>
public static class RenderBackendFactory
{
private static readonly Dictionary<string, Func<int, int, bool, IRenderContext>> _registry
= new(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// Register a backend implementation under the given name.
/// The factory receives (width, height, enableValidation) and must create
/// its own window and render context.
/// </summary>
public static void Register(string name, Func<int, int, bool, IRenderContext> factory)
{
_registry[name] = factory;
}
/// <summary>
/// Create a backend instance for the given name.
/// The backend assembly must have registered itself before this is called.
/// </summary>
public static IRenderContext Create(string name, int width, int height, bool enableValidation)
{
if (!_registry.TryGetValue(name, out var factory))
throw new NotSupportedException($"No graphics backend named '{name}' is registered.");
return factory(width, height, enableValidation);
}
}