From eec26d60f4d569718e633e1f4b0bbf0188844352 Mon Sep 17 00:00:00 2001 From: emil28092005 Date: Wed, 26 Aug 2026 16:50:15 +0300 Subject: [PATCH] feat: add Windows runtime support --- CORTEX_ENGINE_ARCHITECTURE.md | 2 +- README.md | 29 +++++++++++++++++- scripts/run.ps1 | 20 +++++++++++++ scripts/start_mcp_engine.ps1 | 19 ++++++++++++ src/CortexEngine.App/CortexEngine.App.csproj | 9 ++++++ src/CortexEngine.App/Program.cs | 31 ++++++++++++++++---- 6 files changed, 103 insertions(+), 7 deletions(-) create mode 100644 scripts/run.ps1 create mode 100644 scripts/start_mcp_engine.ps1 diff --git a/CORTEX_ENGINE_ARCHITECTURE.md b/CORTEX_ENGINE_ARCHITECTURE.md index b1756e6..dd95b89 100644 --- a/CORTEX_ENGINE_ARCHITECTURE.md +++ b/CORTEX_ENGINE_ARCHITECTURE.md @@ -100,7 +100,7 @@ src/ ### 3.1 Initialization -1. **Load `libvulkan.so.1`** via `NativeLibrary.Load()` +1. **Load the platform Vulkan loader** via `NativeLibrary.Load()` (`vulkan-1.dll` on Windows, `libvulkan.so.1` on Linux) 2. **`vkGetInstanceProcAddr`** — only directly-loaded function 3. **Create instance** with SDL3 extensions + `VK_EXT_debug_utils` (if validation available) 4. **Pick physical device** — prefer `DiscreteGpu` diff --git a/README.md b/README.md index 02e5635..5d02443 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ AI-Native 3D game engine with pure P/Invoke Vulkan 1.3 render backend. - **ECS** — Flecs.NET with Transform, Mesh, Material, Light, Camera, RigidBody components - **SDL3 Window** — cross-platform, Vulkan surface -## Quick Start +## Quick Start — Linux (main platform) ```bash # Build @@ -38,6 +38,33 @@ dotnet build CORTEX_ENGINE.sln -c Debug dotnet test tests/Engine.Tests/Engine.Tests.csproj -c Debug ``` +## Quick Start — Windows x64 + +PowerShell scripts select the Windows native runtime assets explicitly; Bash is +not required: + +```powershell +# Build and restore Windows native dependencies +dotnet restore .\CORTEX_ENGINE.sln -r win-x64 +dotnet build .\CORTEX_ENGINE.sln -c Debug -r win-x64 --no-restore + +# Run the engine +.\scripts\run.ps1 + +# Run a demo scene +.\scripts\run.ps1 --scene shooter + +# Run with AI/MCP server +.\scripts\start_mcp_engine.ps1 -Port 5000 + +# Run tests +dotnet test .\tests\Engine.Tests\Engine.Tests.csproj -c Debug -r win-x64 +``` + +The project keeps Linux as the default RID on Linux hosts and selects `win-x64` +automatically on Windows. Use `-r win-x64` when cross-publishing from another +OS. + ## Controls - **WASD** — move camera diff --git a/scripts/run.ps1 b/scripts/run.ps1 new file mode 100644 index 0000000..29da297 --- /dev/null +++ b/scripts/run.ps1 @@ -0,0 +1,20 @@ +[CmdletBinding()] +param( + [Parameter(ValueFromRemainingArguments = $true)] + [string[]] $EngineArgs +) + +$ErrorActionPreference = 'Stop' +$engineDir = Split-Path -Parent $PSScriptRoot +$project = Join-Path $engineDir 'src/CortexEngine.App/CortexEngine.App.csproj' + +Push-Location $engineDir +try { + & dotnet run --project $project -c Debug -r win-x64 -- @EngineArgs + $exitCode = $LASTEXITCODE +} +finally { + Pop-Location +} + +exit $exitCode diff --git a/scripts/start_mcp_engine.ps1 b/scripts/start_mcp_engine.ps1 new file mode 100644 index 0000000..45c3e12 --- /dev/null +++ b/scripts/start_mcp_engine.ps1 @@ -0,0 +1,19 @@ +[CmdletBinding()] +param( + [int] $Port = 5000 +) + +$ErrorActionPreference = 'Stop' +$engineDir = Split-Path -Parent $PSScriptRoot +$project = Join-Path $engineDir 'src/CortexEngine.App/CortexEngine.App.csproj' + +Push-Location $engineDir +try { + & dotnet run --project $project -c Debug -r win-x64 -- --mcp-port $Port + $exitCode = $LASTEXITCODE +} +finally { + Pop-Location +} + +exit $exitCode diff --git a/src/CortexEngine.App/CortexEngine.App.csproj b/src/CortexEngine.App/CortexEngine.App.csproj index ed1d5ac..ccc4173 100644 --- a/src/CortexEngine.App/CortexEngine.App.csproj +++ b/src/CortexEngine.App/CortexEngine.App.csproj @@ -11,6 +11,15 @@ DEV_MODE + + + + + win-x64 + + linux-x64 diff --git a/src/CortexEngine.App/Program.cs b/src/CortexEngine.App/Program.cs index 3da4ae7..ce1fb7c 100644 --- a/src/CortexEngine.App/Program.cs +++ b/src/CortexEngine.App/Program.cs @@ -408,18 +408,39 @@ class Program var w = window.Width; var h = window.Height; - var ffmpegArgs = $"-y -f rawvideo -pixel_format bgra -video_size {w}x{h} -framerate 60 -i - -c:v libx264 -preset fast -crf 23 -pix_fmt yuv420p -vf fps=30 {recordingPath}"; + var outputPath = recordingPath!; + // ArgumentList avoids shell-specific quoting rules and works + // for paths on both Windows and Linux. var psi = new ProcessStartInfo { FileName = "ffmpeg", - Arguments = ffmpegArgs, UseShellExecute = false, RedirectStandardInput = true, - RedirectStandardOutput = true, - RedirectStandardError = true, CreateNoWindow = true, }; + psi.ArgumentList.Add("-y"); + psi.ArgumentList.Add("-f"); + psi.ArgumentList.Add("rawvideo"); + psi.ArgumentList.Add("-pixel_format"); + psi.ArgumentList.Add("bgra"); + psi.ArgumentList.Add("-video_size"); + psi.ArgumentList.Add($"{w}x{h}"); + psi.ArgumentList.Add("-framerate"); + psi.ArgumentList.Add("60"); + psi.ArgumentList.Add("-i"); + psi.ArgumentList.Add("-"); + psi.ArgumentList.Add("-c:v"); + psi.ArgumentList.Add("libx264"); + psi.ArgumentList.Add("-preset"); + psi.ArgumentList.Add("fast"); + psi.ArgumentList.Add("-crf"); + psi.ArgumentList.Add("23"); + psi.ArgumentList.Add("-pix_fmt"); + psi.ArgumentList.Add("yuv420p"); + psi.ArgumentList.Add("-vf"); + psi.ArgumentList.Add("fps=30"); + psi.ArgumentList.Add(outputPath); try { @@ -431,7 +452,7 @@ class Program catch (Exception ex) { Console.WriteLine($"[App] Failed to start FFmpeg: {ex.Message}"); - Console.WriteLine("[App] Install FFmpeg: sudo apt install ffmpeg"); + Console.WriteLine("[App] Install FFmpeg and ensure the ffmpeg executable is available on PATH."); } } }