From c7ff5ee15dfb29d84d8f9bb358a655c10d36b58f Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Wed, 26 Jul 2023 10:00:46 -0400 Subject: [PATCH] render app icon --- Program.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Program.cs b/Program.cs index ae35134..7b6aeaf 100644 --- a/Program.cs +++ b/Program.cs @@ -1,6 +1,7 @@ using OpenTK.Graphics.OpenGL4; using OpenTK.Mathematics; using OpenTK.Windowing.Common; +using OpenTK.Windowing.Common.Input; using OpenTK.Windowing.Desktop; using OpenTK.Windowing.GraphicsLibraryFramework; // https://docs.sixlabors.com/api/ImageSharp/SixLabors.ImageSharp.Image.html @@ -503,6 +504,18 @@ public static class Util { return texture; } + public static OpenTK.Windowing.Common.Input.Image[] RenderAppIcon() { + Font font = SystemFonts.CreateFont("MS PMincho", 64, FontStyle.Bold); + TextOptions options = new(font); + Image image = MakeImage(64, 64); + IBrush brush = Brushes.Solid(Color.Black); + image.Mutate(x => x.DrawText(options, "撮", brush)); + byte[] pixelBytes = new byte[64 * 64 * 4]; + image.CopyPixelDataTo(pixelBytes); + OpenTK.Windowing.Common.Input.Image opentkImage = new(64, 64, pixelBytes); + return new OpenTK.Windowing.Common.Input.Image[]{ opentkImage }; + } + public static Texture RenderStar(float radius) { IPath path = new Star(x: radius, y: radius, prongs: 5, innerRadii: radius * 0.4f, outerRadii: radius, angle: Util.PI); Image image = MakeImage(path.Bounds.Width, path.Bounds.Height); @@ -894,8 +907,8 @@ static class Program { nwSettings.Size = new Vector2i(bestMonitor.WorkArea.Size.X - 2, bestMonitor.WorkArea.Size.Y - 32); nwSettings.MinimumSize = UiGeometry.MIN_WINDOW_SIZE; nwSettings.Title = "Totte"; - nwSettings.IsEventDriven = true; - // FIXME: nwSettings.Icon = ... + nwSettings.IsEventDriven = false; + nwSettings.Icon = new WindowIcon(Util.RenderAppIcon()); using (Game game = new(gwSettings, nwSettings)) { game.Run();