Skip to content

Commit

Permalink
Merge pull request #136 from Gnimuc/makie
Browse files Browse the repository at this point in the history
Document GLMakie requirements
  • Loading branch information
JamesWrigley authored Aug 4, 2024
2 parents 5542784 + 3f18de0 commit bf62835
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
name: CI

on:
- push
- pull_request
push:
branches:
- master
tags: "*"

permissions:
actions: write
Expand Down
6 changes: 6 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ content creation tools and visualization / debug tools. You could browse
[Gallery](https://github.com/ocornut/imgui/issues/2265) to get an idea of its
use cases.

These docs were generated against this upstream Dear ImGui version:
```@repl
import CImGui as ig
ig.imgui_version()
```

## Installation
```julia-repl
pkg> add CImGui
Expand Down
24 changes: 16 additions & 8 deletions examples/makie_demo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@ ig.set_backend(:GlfwOpenGL3)
function generate_data(type::Symbol=:random, N=1000)
if type === :random
[Point2f(i, rand()) for i in 1:N]
elseif type === :sine
[Point2f(i, sin(i * 0.1) + 0.5) for i in 1:N]
end
end

function HelpMarker(msg)
ig.TextDisabled("(?)");
ig.TextDisabled("(?)")

if ig.IsItemHovered() && ig.BeginTooltip()
ig.PushTextWrapPos(ig.GetFontSize() * 35.0);
ig.TextUnformatted(msg);
ig.PopTextWrapPos();
ig.EndTooltip();
ig.PushTextWrapPos(ig.GetFontSize() * 35.0)
ig.TextUnformatted(msg)
ig.PopTextWrapPos()
ig.EndTooltip()
end
end

Expand All @@ -31,8 +33,11 @@ function makie_demo(; engine=nothing)
scene = Makie.get_scene(f)
ax1 = Axis(f[1, 1]; title="Random data")
data = Observable(generate_data())
lines!(ax1, data)
lines!(ax1, data, label="Random data")
lines!(ax1, generate_data(:sine), label="Sin")
data2 = Observable(generate_data())
axislegend(ax1)

ax2 = Axis(f[2, 1])
lines!(ax2, data2)

Expand All @@ -44,9 +49,10 @@ function makie_demo(; engine=nothing)
ax1_tight_spacing = true
auto_resize_x = true
auto_resize_y = false
tooltip = true

# Start the GUI
ig.render(ctx; engine, window_size=(1280, 760), window_title="ImGui Window") do
ig.render(ctx; engine, window_size=(1280, 760), window_title="ImGui Window", opengl_version=v"3.3") do
ig.Begin("Makie demo")

if ig.Button("Random data")
Expand All @@ -63,8 +69,10 @@ function makie_demo(; engine=nothing)
@c ig.Checkbox("Auto resize X", &auto_resize_x)
ig.SameLine()
@c ig.Checkbox("Auto resize Y", &auto_resize_y)
ig.SameLine()
@c ig.Checkbox("Draw tooltip", &tooltip)

if ig.MakieFigure("plot", f; auto_resize_x, auto_resize_y)
if ig.MakieFigure("plot", f; auto_resize_x, auto_resize_y, tooltip)
if ax1_tight_spacing
Makie.tight_ticklabel_spacing!(ax1)
end
Expand Down
9 changes: 8 additions & 1 deletion src/CImGui.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ const IMGUI_VERSION = unsafe_string(GetVersion())
# This is implemented by the MakieIntegration extension but we document it here
# so that we don't have to install GLMakie to build the docs.
"""
MakieFigure(id::String, f::GLMakie.Figure; auto_resize_x=true, auto_resize_y=false, tooltip=true)
MakieFigure(id::String, f::GLMakie.Figure;
auto_resize_x=true, auto_resize_y=false,
tooltip=true)
Display a Makie figure in ImGui. See `examples/makie_demo.jl` for an example of
how to use it. This supports all the interaction features in GLMakie:
Expand Down Expand Up @@ -104,6 +106,11 @@ Known issues:
- Drawing can be a bit janky, occasionally the image will not be drawn for a
frame or two and you'll see an empty black square instead.
!!! note
GLMakie requires OpenGL 3.3, on some systems you will need to explicitly
pass `opengl_version=v"3.3"` (or higher) to [`render()`](@ref) 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
Expand Down

0 comments on commit bf62835

Please sign in to comment.