From 6d18e0bd3819e991fad01df66316a803bbc16dee Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 10 Apr 2026 16:39:40 +0200 Subject: [PATCH] =?UTF-8?q?feat(app):=20Silk.NET=20window=20smoke=20?= =?UTF-8?q?=E2=80=94=20clear=20to=20navy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Minimal Silk.NET window wiring: 1280x720, OpenGL 4.3 core profile, VSync, dark navy clear color, Escape to close. No rendering beyond the clear call — terrain and shader land in Tasks 8 and 9. Manual smoke: process starts, stays alive past GL context creation, produces no stderr, no uncaught exceptions. Actual visual check will happen end-to-end after Task 10. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/AcDream.App/Program.cs | 6 ++- src/AcDream.App/Rendering/GameWindow.cs | 62 +++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 src/AcDream.App/Rendering/GameWindow.cs diff --git a/src/AcDream.App/Program.cs b/src/AcDream.App/Program.cs index f7c3234..dae3ff3 100644 --- a/src/AcDream.App/Program.cs +++ b/src/AcDream.App/Program.cs @@ -1,3 +1,5 @@ -// src/AcDream.App/Program.cs -Console.WriteLine("acdream app — phase 1 skeleton"); +using AcDream.App.Rendering; + +var window = new GameWindow(); +window.Run(); return 0; diff --git a/src/AcDream.App/Rendering/GameWindow.cs b/src/AcDream.App/Rendering/GameWindow.cs new file mode 100644 index 0000000..9a52fb5 --- /dev/null +++ b/src/AcDream.App/Rendering/GameWindow.cs @@ -0,0 +1,62 @@ +using Silk.NET.Input; +using Silk.NET.Maths; +using Silk.NET.OpenGL; +using Silk.NET.Windowing; + +namespace AcDream.App.Rendering; + +public sealed class GameWindow : IDisposable +{ + private IWindow? _window; + private GL? _gl; + private IInputContext? _input; + + public void Run() + { + var options = WindowOptions.Default with + { + Size = new Vector2D(1280, 720), + Title = "acdream — phase 1", + API = new GraphicsAPI( + ContextAPI.OpenGL, + ContextProfile.Core, + ContextFlags.ForwardCompatible, + new APIVersion(4, 3)), + VSync = true, + }; + + _window = Window.Create(options); + _window.Load += OnLoad; + _window.Render += OnRender; + _window.Closing += OnClosing; + + _window.Run(); + } + + private void OnLoad() + { + _gl = GL.GetApi(_window!); + _input = _window!.CreateInput(); + foreach (var kb in _input.Keyboards) + kb.KeyDown += (_, key, _) => + { + if (key == Key.Escape) + _window!.Close(); + }; + + _gl.ClearColor(0.05f, 0.10f, 0.18f, 1.0f); + } + + private void OnRender(double deltaSeconds) + { + _gl!.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); + } + + private void OnClosing() + { + _input?.Dispose(); + _gl?.Dispose(); + } + + public void Dispose() => _window?.Dispose(); +}