Backends
ImGui is a very embeddable library because it abstracts things like drawing to the screen and creating windows to its backends. There are many official backends, but currently CImGui.jl only supports the GLFW/OpenGL3 backend.
CImGui.set_backend
— Functionset_backend(backend::Symbol)
Set the backend to use. Currently supported backends are:
:GlfwOpenGL3
(GLFW/OpenGL3, requires ModernGL.jl and GLFW.jl)
CImGui.render
— Functionrender(ui::Function, ctx::Ptr{lib.ImGuiContext}; kwargs...)
Top-level function to call a renderloop implemented by the backend selected by set_backend()
. This function will not return until the program exits, either by the user closing the window or ui()
returning :imgui_exit_loop
. It will also not yield the loop, though you may explicitly call yield()
in ui()
.
Arguments
Positional arguments:
ui
: The function to execute in the renderloop. This where all the GUI code with calls to CImGui should go.ctx
: The ImGui context to use. Note thatDestroyContext()
will automatically be called on it at the end of the renderloop, so it will be unusable afterwards.
Keyword arguments:
hotloading=true
: Enable calling the latest version ofui()
using@invokelatest
. This is handy when using Revise.jl.on_exit::Union{Function, Nothing}=nothing
: A destructor/finalizer function that will be called before destroyingctx
. This might be useful if you're using some external library that needs to be cleaned up in a certain order.clear_color=Cfloat[0.45, 0.55, 0.60, 1.00]
: The color of the window background. This can also be aRef{Vector{Cfloat}}
if you want to control the color dynamically (see the official demo for an example).window_size=(1280, 720)
: The initial size of the window.window_title="CImGui"
: The window title.engine=nothing
: An optionalImGuiTestEngine.Engine
instance. If there are any tests registered with the test engine they will be queued and run automatically.opengl_version::VersionNumber=v"3.2"
: The OpenGL version to use.