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

Error in CImGui GlfwOpenGL3 renderloop! #149

Open
moe93 opened this issue Sep 13, 2024 · 3 comments
Open

Error in CImGui GlfwOpenGL3 renderloop! #149

moe93 opened this issue Sep 13, 2024 · 3 comments

Comments

@moe93
Copy link

moe93 commented Sep 13, 2024

Hello,

I am trying to get started with CImGui.jl and seem to have trouble getting anything to work properly. I am running on a Windows 10 machine, with Julia 1.10.5.

I started a project and have the following installed

(MyProject) pkg> status
Project MyProject v0.1.0
Status `path\to\MyProject.jl\Project.toml`
  [5d785b6c] CImGui v3.0.0
  [f7f18e0c] GLFW v3.4.3
  [66fc600b] ModernGL v1.1.7

(MyProject) pkg>

I initially attempted to run the demo and examples and had trouble running either. So I decided to attempt something simpler and easier to trace. I copied the example 'Your First Gui \o/' and tried to run it. For the sake of completeness, here is the code used.

import CImGui as ig, ModernGL, GLFW
ig.set_backend(:GlfwOpenGL3)
ctx = ig.CreateContext()
ig.render(ctx; window_size=(360, 480), window_title="ImGui Window") do
    ig.Begin("Hello ImGui")
    if ig.Button("My Button")
        @info "Triggered"
    end
    ig.End()
end

The window opens up just fine, but about 10 seconds later, it crashes on its own giving the following error message

┌ Error: Error in CImGui GlfwOpenGL3 renderloop!
│   exception =
│    GLFWError (PLATFORM_ERROR): WGL: Failed to make context current: The requested transformation operation is not supported.
│    Stacktrace:
│     [1] _ErrorCallbackWrapper(code::Int32, description::Cstring)
│       @ GLFW path\to\.julia\packages\GLFW\wmoTL\src\callback.jl:43
│     [2] MakeContextCurrent
│       @ path\to\.julia\packages\GLFW\wmoTL\src\glfw3.jl:776 [inlined]
│     [3] renderloop(ui::var"#19#20", ctx::Ptr{CImGui.lib.ImGuiContext}, ::Val{:GlfwOpenGL3}; hotloading::Bool, on_exit::Nothing, clear_color::Vector{Float32}, window_size::Tuple{Int64, Int64}, window_title::String, engine::Nothing, opengl_version::VersionNumber)
│       @ GlfwOpenGLBackend path\to\.julia\packages\CImGui\nVW4u\ext\GlfwOpenGLBackend.jl:125
│     [4] renderloop
│       @ path\to\.julia\packages\CImGui\nVW4u\ext\GlfwOpenGLBackend.jl:54 [inlined]
│     [5] (::GlfwOpenGLBackend.var"#5#6"{@Kwargs{window_size::Tuple{Int64, Int64}, window_title::String}, Tuple{var"#19#20", Ptr{CImGui.lib.ImGuiContext}, Val{:GlfwOpenGL3}}})()
│       @ GlfwOpenGLBackend path\to\.julia\packages\CImGui\nVW4u\ext\GlfwOpenGLBackend.jl:176
└ @ GlfwOpenGLBackend path\to\.julia\packages\CImGui\nVW4u\ext\GlfwOpenGLBackend.jl:147

Any ideas?

@JamesWrigley
Copy link
Member

What happens if you pin GLFW_jll to 3.3?

@moe93
Copy link
Author

moe93 commented Sep 13, 2024

Pining GLFW v3.3.0 doesn't resolve the issue.

I seem to have figured out the issue though; the OpenGL version. Changing it in the renderer to opengl_version=v"3.0" fixes the problem, did not realize the default was set to v"3.2" in the renderer.

I double checked with my C++ imgui code and I do use 3.0 there as well. However, if I specify version 3.2 in the C++ imgui program, everything runs fine with no issues. I am not so sure why that is an issue when it comes to the Julia one.

@JamesWrigley
Copy link
Member

Pining GLFW v3.3.0 doesn't resolve the issue.

I meant GLFW_jll though :) GLFW.jl's version numbering doesn't match the version of the GLFW library that's used. I'm wondering about this because GLFW 3.4 was quite a large release.

I seem to have figured out the issue though; the OpenGL version. Changing it in the renderer to opengl_version=v"3.0" fixes the problem, did not realize the default was set to v"3.2" in the renderer.

I double checked with my C++ imgui code and I do use 3.0 there as well. However, if I specify version 3.2 in the C++ imgui program, everything runs fine with no issues. I am not so sure why that is an issue when it comes to the Julia one.

Oh interesting, I would've thought an OpenGL version problem would manifest sooner 🤔 I believe there are some differences between the renderloop we implement and the official example with GLFW/OpenGL3 but I never looked into the differences. Perhaps that's causing it.

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