Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenTK implimentation? #2

Open
Shadowblitz16 opened this issue Nov 14, 2022 · 3 comments
Open

OpenTK implimentation? #2

Shadowblitz16 opened this issue Nov 14, 2022 · 3 comments

Comments

@Shadowblitz16
Copy link

Shadowblitz16 commented Nov 14, 2022

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
Copy link
Author

Shadowblitz16 commented Nov 14, 2022

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
Copy link
Author

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

@Sewer56
Copy link
Owner

Sewer56 commented Nov 14, 2022

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 👆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants