-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
95 lines (80 loc) · 3.12 KB
/
Copy pathProgram.cs
File metadata and controls
95 lines (80 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// This file is part of Silk.NET.
//
// You may modify and distribute Silk.NET under the terms
// of the MIT license. See the LICENSE file for details.
using System.Drawing;
using Demo;
using Friflo.EcGui;
using Silk.NET.Windowing;
using Silk.NET.Input;
using Silk.NET.Maths;
using Silk.NET.OpenGL;
using Silk.NET.OpenGL.Extensions.ImGui;
namespace ImGui
{
class Program
{
static void Main(string[] args)
{
// Create a Silk.NET window as usual
using var window = Window.Create(WindowOptions.Default);
// Declare some variables
ImGuiController controller = null!;
GL gl = null!;
IInputContext inputContext = null!;
// Our loading function
window.Load += () =>
{
controller = new ImGuiController(
gl = window.CreateOpenGL(), // load OpenGL
window, // pass in our window
inputContext = window.CreateInput(), // create an input context
ImGuiUtils.ConfigureIO
);
};
var size = Silk.NET.Windowing.Monitor.GetMainMonitor(window).Bounds.Size;
window.Size = new Vector2D<int>((int)(0.8 * size.X), (int)(0.8 * size.Y));
window.VSync = false;
window.Title = "friflo EcGui - Silk.NET.OpenGL";
DemoECS.CustomizeEcGui(); // customize UI
DemoECS.CreateEntityStore(); // set up your ECS here
// Handle resizes
window.FramebufferResize += s =>
{
// Adjust the viewport to the new window size
gl.Viewport(s);
};
// The render function
window.Render += delta =>
{
// Make sure ImGui is up-to-date
controller.Update((float) delta);
// This is where you'll do any rendering beneath the ImGui context
// Here, we just have a blank screen.
gl.ClearColor(Color.FromArgb(255, (int) (.45f * 255), (int) (.55f * 255), (int) (.60f * 255)));
gl.Clear((uint) ClearBufferMask.ColorBufferBit);
// This is where you'll do all of your ImGUi rendering
// Here, we're just showing the ImGui built-in demo window.
// ImGuiNET.ImGui.ShowDemoWindow();
EcGui.HistorySnapshot(); // optional - required to show histories
EcGui.ExplorerWindow();
EcGui.InspectorWindow();
// Make sure ImGui renders too!
controller.Render();
};
// The closing function
window.Closing += () =>
{
// Dispose our controller first
controller?.Dispose();
// Dispose the input context
inputContext?.Dispose();
// Unload OpenGL
gl?.Dispose();
};
// Now that everything's defined, let's run this bad boy!
window.Run();
window.Dispose();
}
}
}