Browse Source

render app icon

main
Colin McMillen 12 months ago
parent
commit
c7ff5ee15d
  1. 17
      Program.cs

17
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<Rgba32> 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<Rgba32> 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();

Loading…
Cancel
Save