render app icon
This commit is contained in:
parent
07d25742fb
commit
c7ff5ee15d
17
Program.cs
17
Program.cs
@ -1,6 +1,7 @@
|
|||||||
using OpenTK.Graphics.OpenGL4;
|
using OpenTK.Graphics.OpenGL4;
|
||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
using OpenTK.Windowing.Common;
|
using OpenTK.Windowing.Common;
|
||||||
|
using OpenTK.Windowing.Common.Input;
|
||||||
using OpenTK.Windowing.Desktop;
|
using OpenTK.Windowing.Desktop;
|
||||||
using OpenTK.Windowing.GraphicsLibraryFramework;
|
using OpenTK.Windowing.GraphicsLibraryFramework;
|
||||||
// https://docs.sixlabors.com/api/ImageSharp/SixLabors.ImageSharp.Image.html
|
// https://docs.sixlabors.com/api/ImageSharp/SixLabors.ImageSharp.Image.html
|
||||||
@ -503,6 +504,18 @@ public static class Util {
|
|||||||
return texture;
|
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) {
|
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);
|
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);
|
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.Size = new Vector2i(bestMonitor.WorkArea.Size.X - 2, bestMonitor.WorkArea.Size.Y - 32);
|
||||||
nwSettings.MinimumSize = UiGeometry.MIN_WINDOW_SIZE;
|
nwSettings.MinimumSize = UiGeometry.MIN_WINDOW_SIZE;
|
||||||
nwSettings.Title = "Totte";
|
nwSettings.Title = "Totte";
|
||||||
nwSettings.IsEventDriven = true;
|
nwSettings.IsEventDriven = false;
|
||||||
// FIXME: nwSettings.Icon = ...
|
nwSettings.Icon = new WindowIcon(Util.RenderAppIcon());
|
||||||
|
|
||||||
using (Game game = new(gwSettings, nwSettings)) {
|
using (Game game = new(gwSettings, nwSettings)) {
|
||||||
game.Run();
|
game.Run();
|
||||||
|
Loading…
Reference in New Issue
Block a user