-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathtest.cpp
More file actions
42 lines (38 loc) · 1.12 KB
/
test.cpp
File metadata and controls
42 lines (38 loc) · 1.12 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 <cstdlib>
#include "../imgui.h" // > imgui headers (+imgui_app definitions)
char buf[128];
float f;
ImTextureID tex = 0;
void frame() {
ImGui::Text("Hello, world %d", 123);
if (ImGui::Button("Button")) {
buf[0] = 0;
f = 1.0f;
}
ImGui::InputText("string", buf, IM_ARRAYSIZE(buf));
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
if (tex == 0) {
unsigned char buffer[32*32*4];
for(int i = 0; i < 32*32; ++i) {
buffer[i*4+0] = std::rand()%255;
buffer[i*4+1] = std::rand()%255;
buffer[i*4+2] = std::rand()%255;
buffer[i*4+3] = 255;
}
tex = imgui_app_loadImageRGBA8(buffer, 32, 32);
}
ImGui::Image(tex, {256, 256});
ImGui::ShowDemoWindow();
}
int main(int, char **) {
// do any initialization
buf[0] = 0;
f = 0.0f;
// when ready start the UI (this will not return until the app finishes)
int imguiConfigFlags = 0;
#ifdef IMGUI_HAS_DOCK
imguiConfigFlags |= ImGuiConfigFlags_DockingEnable;
#endif
imgui_app(frame, "IMGUI_APP", 800, 600, imguiConfigFlags);
return 0;
}