DearImguiSharp icon indicating copy to clipboard operation
DearImguiSharp copied to clipboard

OpenTK implimentation?

Open Shadowblitz16 opened this issue 3 years ago • 3 comments

Is there a way to implement this with opentk both through GameWindow and GLFW? I tried doing it the GLFW way and it won't let me cast my void pointer to your GLFWWindow class

    ImGui.ImGuiImplGlfwInitForOpenGL((GLFWwindow)window.ID.ToPointer(), true);

Shadowblitz16 avatar Nov 14 '22 05:11 Shadowblitz16

Fixed previous issue but.. Turns out I get this when using opentk...

/usr/bin/dotnet: symbol lookup error: /home/shadowblitz16/Documents/source/ZealEngine/bin/Debug/net6.0/runtimes/linux-x64/native/cimgui.so: undefined symbol: glfwSetErrorCallback
using DearImguiSharp;
//using GLFWWindow = OpenTK.Windowing.GraphicsLibraryFramework.Window;
using (var window = new Window(1080, 720, "Zeal"))
{
    var _context = ImGui.CreateContext(null);
    ImGui.StyleColorsDark(null);

    unsafe { ImGui.ImGuiImplGlfwInitForOpenGL(new GLFWwindow(window.ID.ToPointer()), true); }

    float[] vertices =
    {
        -0.5f, -0.5f, 0.0f,
        +0.5f, -0.5f, 0.0f,
        +0.0f, +0.5f, 0.0f
    };


    while (window.IsRunning(0x0000ffff))
    {   
        var open = false;
        ImGui.ImGuiImplOpenGL2NewFrame();
        ImGui.ShowDemoWindow(ref open);
        ImGui.ImGuiImplOpenGL2RenderDrawData(ImGui.GetDrawData());
    }

    ImGui.ImGuiImplOpenGL2Shutdown();
    ImGui.DestroyContext(_context);

    window.Dispose();
}

Shadowblitz16 avatar Nov 14 '22 19:11 Shadowblitz16

I also did a objdump here for your cimgui cimgui.txt

Shadowblitz16 avatar Nov 14 '22 20:11 Shadowblitz16

I don't write native code often but if I were to have a guess it's down to the GLFW code in the wrapper not being properly configured for dynamic linking. When I added the bindings, I did the minimal required work to get CI/CD working over at NativeBuilds which uses my fork of cimgui, and I've never gotten around to testing anything other than DirectX (which is always dynamically linked since it is based on COM).

If I were to guess you might need to add some GLFW related defines in the cimgui fork, then see how goes: https://github.com/ocornut/imgui/blob/6d5388448794f76cc92576a74ad3cb17da2fca84/examples/libs/glfw/include/GLFW/glfw3.h#L178

They appear to be defined around there 👆

Sewer56 avatar Nov 14 '22 22:11 Sewer56