-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello_world.cpp
More file actions
42 lines (33 loc) · 1.2 KB
/
hello_world.cpp
File metadata and controls
42 lines (33 loc) · 1.2 KB
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
#include <functional>
#include "DearImKit/dearimkit.h"
// Extend base class
class HelloWorld : public DearImKit::Panel {
public:
// Call base class constructor
HelloWorld(int num_times = 1) : DearImKit::Panel("Hello World"), m_num_times(num_times) {};
// Override draw function
bool draw() override {
bool stay_open = true;
// Check out https://github.com/ocornut/imgui for guide to ImGui logic
if (!DearImKit::Begin(*this, &stay_open)) {
ImGui::End();
return stay_open;
}
for (int i = 0; i < m_num_times; i++) {
ImGui::Text("Hello World from DearImKit");
}
ImGui::End();
return stay_open;
}
private:
int m_num_times;
};
int main() {
// Add windows to be displayed at startup with a std::function that will be passed to DearImKit::SetupApp(...)
std::function<void(void)> at_start = []() {
DearImKit::AddPanel<HelloWorld>(2);
};
// Can optionally set the parameters for the function to execute once per application loop and background color
// Usually the once per loop function should be left blank, background color is safe to change
DearImKit::SetupApp(at_start);
}