Run the following code snippet with Silk.Net 2.21.0
// 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 Silk.NET.Windowing;
using Silk.NET.Input;
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
);
};
// 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();
// 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();
}
}
}
And we got the error
Unhandled exception. System.MissingMethodException: Method not found: 'ImGuiNET.RangeAccessor`1<Int32> ImGuiNET.ImGuiIOPtr.get_KeyMap()'.
at Silk.NET.OpenGL.Extensions.ImGui.ImGuiController.SetKeyMappings()
at Silk.NET.OpenGL.Extensions.ImGui.ImGuiController..ctor(GL gl, IView view, IInputContext input, Nullable`1 imGuiFontConfig, Action onConfigureIO)
at Silk.NET.OpenGL.Extensions.ImGui.ImGuiController..ctor(GL gl, IView view, IInputContext input)
at ImGui.Program.<>c__DisplayClass0_0.<Main>b__0() in /Users/me/workspace/Test/Client/Program.cs:line 29
at Silk.NET.Windowing.Internals.ViewImplementationBase.Initialize()
at Silk.NET.Windowing.WindowExtensions.Run(IView view)
at ImGui.Program.Main(String[] args) in /Users/me/workspace/Test/Client/Program.cs:line 76
Process finished with exit code 134.
Comments
Add any other context about the problem here.
If you know how to fix this issue, please submit a pull request instead!
Summary
A summary of the issue you're experiencing.
Steps to reproduce
Comments
Add any other context about the problem here.
If you know how to fix this issue, please submit a pull request instead!