- 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
2.8 KiB
2.8 KiB
AGENTS.md — Cortex Engine
Project Overview
Cortex Engine is a C# (.NET 9) AI-Native 3D game engine. The primary render backend is Raylib-cs (OpenGL). A Vulkan backend exists but is deferred.
Build Commands
# Build (Debug)
dotnet build CORTEX_ENGINE.sln -c Debug
# Build (Release)
dotnet build CORTEX_ENGINE.sln -c Release
# Run the engine
./scripts/run.sh
# Run with test scene + camera tour (headless screenshot capture)
dotnet run --project src/CortexEngine.App/CortexEngine.App.csproj -c Release -- --test-scene --camera-tour --mcp-port 0
# Run with MCP server
./scripts/run.sh --mcp-port 5000
Lint / Typecheck
No separate lint command. dotnet build with 0 warnings is the standard. Run dotnet build CORTEX_ENGINE.sln -c Release to verify.
Architecture
- Engine.Core —
IWindow,IInputState,Keyenum,Sdl3Window, camera controllers, ECS components (Transform,Mesh,Material,Light,Camera),Timing - Engine.Graphics — HAL interfaces (
IRenderContext,IRenderer),RenderBackendFactory, mesh loaders (ObjLoader,GltfLoader) - Engine.Graphics.Raylib — Primary backend.
RaylibWindow(GLFW),RaylibInputState,RaylibRendererwith custom GLSL 330 shader (Fresnel, ACES, gamma) - Engine.Graphics.Vulkan — Deferred backend. Compiles but untested. Uses
Sdl3Windowfor Vulkan surface. - Engine.AI —
AiCommandProcessor(7 commands), MCP HTTP + stdio servers - CortexEngine.App — Entry point, main loop, scene setup
Key Conventions
- Each render backend owns its window (
IWindow). The app gets the window fromIRenderContext.Window. - Input is backend-agnostic via
IInputState+Keyenum. No SDL3 types in app code. - Camera controllers use
IInputState, notInputMappingdirectly. RenderBackendFactory.Create(name, width, height, validation)— backends register by name.- Custom mesh CPU data uses
NativeMemory.Alloc(notMarshal.AllocHGlobal) to match Raylib'sRL_FREE. SetShaderValueusesfloat[]for vectors, notVector3/Vector4(marshaling reliability).- Backface culling disabled (
Rlgl.DisableBackfaceCulling) for mixed-winding meshes.
Current Roadmap
See CORTEX_ENGINE_ARCHITECTURE.md §11 for the full roadmap. Short-term priorities:
- Unit tests
- Texture loading verification
- ImGui integration (medium-term)
Files Not to Edit
CORTEX_ENGINE_ARCHITECTURE.md— canonical architecture reference, update only when architecture changessrc/Engine.Graphics.Vulkan/Shaders/*.spv— compiled SPIR-V, regenerate from.vert/.fragwith glslangValidator
Environment
- .NET 9 SDK at
$HOME/.dotnet DOTNET_ROOTandPATHmust include$HOME/.dotnet- Raylib-cs 8.0.0 (Raylib 6.0 native library bundled in NuGet)
- Display required (X11/Wayland) for Raylib window