-
Notifications
You must be signed in to change notification settings - Fork 3
/
hello_world.cpp
76 lines (60 loc) · 2.01 KB
/
hello_world.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Part of ImGui Bundle - MIT License - Copyright (c) 2022-2024 Pascal Thomet - https://github.com/pthom/imgui_bundle
#include "immapp/immapp.h"
#ifdef IMGUI_BUNDLE_WITH_IMPLOT
#include "implot/implot.h"
#endif
#include "imgui_md_wrapper.h"
#include <cmath>
void DemoImplot()
{
static std::vector<double> x, y1, y2;
if (x.empty())
{
double pi = 3.1415;
for (int i = 0; i < 1000; ++i)
{
double x_ = pi * 4. * (double)i / 1000.;
x.push_back(x_);
y1.push_back(cos(x_));
y2.push_back(sin(x_));
}
}
ImGuiMd::Render("# This is the plot of _cosinus_ and *sinus*");
#ifdef IMGUI_BUNDLE_WITH_IMPLOT
if (ImPlot::BeginPlot("Plot"))
{
ImPlot::PlotLine("y1", x.data(), y1.data(), (int)x.size());
ImPlot::PlotLine("y2", x.data(), y2.data(), (int)x.size());
ImPlot::EndPlot();
}
#endif
}
void Gui()
{
ImGuiMd::RenderUnindented(R"(
# Dear ImGui Bundle
[Dear ImGui Bundle](https://github.com/pthom/imgui_bundle) is a bundle for [Dear ImGui](https://github.com/ocornut/imgui.git), including various useful libraries from its ecosystem.
It enables to easily create ImGui applications in C++, as well as in Python.
This is an example of markdown widget, with an included image:
![world](images/world.png)
---
And below is a graph created with ImPlot:
)");
DemoImplot();
ImGui::Separator();
ImGuiMd::RenderUnindented("*Note: the icon of this application is defined by `assets/app_settings/icon.png`*");
}
int main(int , char *[])
{
#ifdef ASSETS_LOCATION
HelloImGui::SetAssetsFolder(ASSETS_LOCATION);
#endif
HelloImGui::SimpleRunnerParams runnnerParams;
runnnerParams.guiFunction = Gui;
runnnerParams.windowSize = {600, 800};
ImmApp::AddOnsParams addOnsParams;
addOnsParams.withMarkdown = true;
addOnsParams.withImplot = true;
ImmApp::Run(runnnerParams, addOnsParams);
return 0;
}