using System;
using ImGuiNET;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.Desktop;
namespace ImGuiWithOpenTK
{
class Program
{
private static GameWindow gameWindow;
public static void Main(string[] args)
{
NativeWindowSettings nativeWindowSettings = new NativeWindowSettings
{
Size = new Vector2i(800, 600),
Title = "ImGui with OpenTK",
API = ContextAPI.OpenGL,
APIVersion = new Version(4, 6),
};
GameWindowSettings gameWindowSettings = new GameWindowSettings
{
UpdateFrequency = 60
};
gameWindow = new GameWindow(gameWindowSettings, nativeWindowSettings);
gameWindow.Load += GameWindow_Load;
gameWindow.RenderFrame += GameWindow_RenderFrame;
gameWindow.UpdateFrame += GameWindow_UpdateFrame;
gameWindow.Run();
}
private static void GameWindow_UpdateFrame(FrameEventArgs obj)
{
}
private static void GameWindow_RenderFrame(FrameEventArgs obj)
{
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
ImGui.NewFrame();
ImGui.Begin("Demo windows");
ImGui.Text("Hello world");
ImGui.End();
ImGui.Render();
gameWindow.SwapBuffers();
}
private static void GameWindow_Load()
{
GL.ClearColor(Color4.CornflowerBlue);
ImGui.CreateContext();
ImGuiIOPtr io = ImGui.GetIO();
ImGui.StyleColorsDark();
}
}
}