Skip to content

Commit 5f15fdf

Browse files
committed
Added ImPlot demo window to sample program
1 parent 13ce5ec commit 5f15fdf

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/ImGui.NET.SampleProgram/ImGui.NET.SampleProgram.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<ProjectReference Include="..\ImGui.NET\ImGui.NET.csproj" />
1111
<PackageReference Include="Veldrid" Version="4.3.3" />
1212
<PackageReference Include="Veldrid.StartupUtilities" Version="4.3.3" />
13+
<ProjectReference Include="..\ImPlot.NET\ImPlot.NET.csproj" />
1314
</ItemGroup>
1415

1516
<ItemGroup>

src/ImGui.NET.SampleProgram/ImGuiController.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public ImGuiController(GraphicsDevice gd, OutputDescription outputDescription, i
6161

6262
IntPtr context = ImGui.CreateContext();
6363
ImGui.SetCurrentContext(context);
64+
IntPtr implotContext = ImPlot.CreateContext();
65+
ImPlot.SetCurrentContext(implotContext);
6466
var fonts = ImGui.GetIO().Fonts;
6567
ImGui.GetIO().Fonts.AddFontDefault();
6668

src/ImGui.NET.SampleProgram/Program.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class Program
2222
private static int _counter = 0;
2323
private static int _dragInt = 0;
2424
private static Vector3 _clearColor = new Vector3(0.45f, 0.55f, 0.6f);
25-
private static bool _showDemoWindow = true;
25+
private static bool _showImGuiDemoWindow = true;
26+
private static bool _showImPlotDemoWindow = false;
2627
private static bool _showAnotherWindow = false;
2728
private static bool _showMemoryEditor = false;
2829
private static byte[] _memoryEditorData;
@@ -89,7 +90,8 @@ private static unsafe void SubmitUI()
8990

9091
ImGui.Text($"Mouse position: {ImGui.GetMousePos()}");
9192

92-
ImGui.Checkbox("Demo Window", ref _showDemoWindow); // Edit bools storing our windows open/close state
93+
ImGui.Checkbox("ImGui Demo Window", ref _showImGuiDemoWindow); // Edit bools storing our windows open/close state
94+
ImGui.Checkbox("ImPlot Demo Window", ref _showImPlotDemoWindow); // Edit bools storing our windows open/close state
9395
ImGui.Checkbox("Another Window", ref _showAnotherWindow);
9496
ImGui.Checkbox("Memory Editor", ref _showMemoryEditor);
9597
if (ImGui.Button("Button")) // Buttons return true when clicked (NB: most widgets return true when edited/activated)
@@ -114,12 +116,17 @@ private static unsafe void SubmitUI()
114116
}
115117

116118
// 3. Show the ImGui demo window. Most of the sample code is in ImGui.ShowDemoWindow(). Read its code to learn more about Dear ImGui!
117-
if (_showDemoWindow)
119+
if (_showImGuiDemoWindow)
118120
{
119121
// Normally user code doesn't need/want to call this because positions are saved in .ini file anyway.
120122
// Here we just want to make the demo initial state a bit more friendly!
121123
ImGui.SetNextWindowPos(new Vector2(650, 20), ImGuiCond.FirstUseEver);
122-
ImGui.ShowDemoWindow(ref _showDemoWindow);
124+
ImGui.ShowDemoWindow(ref _showImGuiDemoWindow);
125+
}
126+
127+
if (_showImPlotDemoWindow)
128+
{
129+
ImPlot.ShowDemoWindow(ref _showImPlotDemoWindow);
123130
}
124131

125132
if (ImGui.TreeNode("Tabs"))

0 commit comments

Comments
 (0)