Makie integration

We currently have very experimental Makie support through GLMakie. GLMakie mostly works around a Screen{T} object to display a scene, where T is some OpenGL-supporting window. GLMakie sets this to a GLFW.Window, but we've made a custom window type to represent a single Figure to be drawn in ImGui. What we get from GLMakie is a framebuffer with a color image texture attachment, and that's displayed by us as an image.

It supports all the interaction features in GLMakie:

  • Scroll to zoom
  • Click and drag to rectangle select a region to zoom to
  • Right click and drag to pan
  • Shift + {x/y} and scroll to zoom along the X/Y axes
  • Ctrl + left click to reset the limits

Here's a quick demo using examples/makie_demo.jl (you may want to Right click -> Open in new tab to see it in full resolution): Makie demo

Thread safety

None of this is thread-safe. Here's what you can and can't do:

  • You can create a Figure on any thread and pass it to MakieFigure() to display.
  • You cannot call MakieFigure() (or generally any ImGui functions) on a different thread from the render() thread.
  • You cannot update a Figure from a separate thread, including with observables. Updating it from the same thread (i.e. in the renderloop) is fine.

API

CImGui.MakieFigureFunction
MakieFigure(id::String, f::GLMakie.Figure;
            auto_resize_x=true, auto_resize_y=false,
            tooltip=true, stats=false)

Display a Makie figure in ImGui. See examples/makie_demo.jl for an example of how to use it.

These are the interaction events that are wired up and can be used:

  • hasfocus
  • entered_window
  • mousebutton
  • mouseposition

Known issues:

  • Mouse events aren't delivered unless the mouse is hovered over the figure, so dragging the mouse from within the figure to somewhere outside the figure will keep the old mouse state. e.g. if you're RMB panning and the mouse goes outside the figure, when it enters the figure again panning will resume even the RMB was released.
  • Note that scrolling to zoom will also cause the ImGui window to scroll, which can be annoying. This may be fixed in the future by using some other key combination for scrolling to zoom.
  • Sometimes zooming way out or in can trigger segfaults if a CImGui window has been opened multiple times in the same process (e.g. when experimenting in the REPL). Some resources probably aren't getting cleaned up properly.
Note

GLMakie requires OpenGL 3.3, on some systems you will need to explicitly pass opengl_version=v"3.3" (or higher) to render() to fix OpenGL shader errors.

Warning

This is very experimental, you will almost definitely encounter bugs (and if so please submit an issue/PR). We don't consider this covered under semver yet so there may be breaking changes in minor releases.