|
| 1 | +#include "DebugGUI/imgui.h" |
| 2 | +#include <stdio.h> |
| 3 | + |
| 4 | +static void error_callback(int error, const char* description) |
| 5 | +{ |
| 6 | + fprintf(stderr, "Error %d: %s\n", error, description); |
| 7 | +} |
| 8 | + |
| 9 | +int main(int, char**) |
| 10 | +{ |
| 11 | + IMGUI_CHECKVERSION(); |
| 12 | + ImGui::CreateContext(); |
| 13 | + ImGuiIO& io = ImGui::GetIO(); |
| 14 | + |
| 15 | + // Build atlas |
| 16 | + unsigned char* tex_pixels = nullptr; |
| 17 | + int tex_w, tex_h; |
| 18 | + io.Fonts->GetTexDataAsRGBA32(&tex_pixels, &tex_w, &tex_h); |
| 19 | + |
| 20 | + bool show_test_window = true; |
| 21 | + bool show_another_window = true; |
| 22 | + ImVec4 clear_color = ImColor(114, 144, 154); |
| 23 | + |
| 24 | + for (int n = 0; n < 50; n++) { |
| 25 | + io.DisplaySize = ImVec2(1920, 1080); |
| 26 | + io.DeltaTime = 1.0f / 60.0f; |
| 27 | + ImGui::NewFrame(); |
| 28 | + |
| 29 | + // 1. Show a simple window |
| 30 | + // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug" |
| 31 | + static float f = 0.0f; |
| 32 | + ImGui::Text("Hello, world!"); |
| 33 | + ImGui::SliderFloat("float", &f, 0.0f, 1.0f); |
| 34 | + ImGui::ColorEdit3("clear color", (float*)&clear_color); |
| 35 | + if (ImGui::Button("Test Window")) show_test_window ^= 1; |
| 36 | + if (ImGui::Button("Another Window")) show_another_window ^= 1; |
| 37 | + ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); |
| 38 | + |
| 39 | + // 2. Show another simple window, this time using an explicit Begin/End pair |
| 40 | + ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver); |
| 41 | + ImGui::Begin("Another Window", &show_another_window); |
| 42 | + ImGui::Text("Hello"); |
| 43 | + ImGui::End(); |
| 44 | + |
| 45 | + ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver); |
| 46 | + ImGui::ShowDemoWindow(nullptr, true); |
| 47 | + |
| 48 | + ImGui::Render(); |
| 49 | + } |
| 50 | + |
| 51 | + ImGui::DestroyContext(); |
| 52 | + |
| 53 | + return 0; |
| 54 | +} |
0 commit comments