mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-23 16:16:36 +00:00
74 lines
2.8 KiB
C++
74 lines
2.8 KiB
C++
//
|
|
// debug_hud.cpp
|
|
// imguiex
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "debug_hud.h"
|
|
#include "imgui.h"
|
|
|
|
void DebugHUD_InitDefaults( DebugHUD *hud )
|
|
{
|
|
hud->show_demo_window = true;
|
|
hud->show_another_window = true;
|
|
hud->rotation_speed = 15.0f;
|
|
|
|
hud->cubeColor1[0] = 0.4f;
|
|
hud->cubeColor1[1] = 0.4f;
|
|
hud->cubeColor1[2] = 1.0f;
|
|
hud->cubeColor1[3] = 1.0f;
|
|
|
|
hud->cubeColor2[0] = 1.0f;
|
|
hud->cubeColor2[1] = 0.4f;
|
|
hud->cubeColor2[2] = 0.4f;
|
|
hud->cubeColor2[3] = 1.0f;
|
|
|
|
hud->clearColor[0] = 0.45f;
|
|
hud->clearColor[1] = 0.55f;
|
|
hud->clearColor[2] = 0.60f;
|
|
hud->clearColor[3] = 1.00f;
|
|
}
|
|
|
|
void DebugHUD_DoInterface(DebugHUD *hud)
|
|
{
|
|
// 1. Show a simple window.
|
|
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
|
|
{
|
|
static float f = 0.0f;
|
|
static int counter = 0;
|
|
ImGui::Text("Hello, world!"); // Display some text (you can use a format string too)
|
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
|
ImGui::ColorEdit3("clear color", hud->clearColor); // Edit 3 floats representing a color
|
|
|
|
ImGui::Checkbox("Demo Window", &hud->show_demo_window); // Edit bools storing our windows open/close state
|
|
ImGui::Checkbox("Another Window", &hud->show_another_window);
|
|
|
|
if (ImGui::Button("Button")) // Buttons return true when clicked (NB: most widgets return true when edited/activated)
|
|
counter++;
|
|
ImGui::SameLine();
|
|
ImGui::Text("counter = %d", counter);
|
|
|
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
|
}
|
|
|
|
// 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name your windows.
|
|
if (hud->show_another_window)
|
|
{
|
|
ImGui::Begin("Another Window", &hud->show_another_window);
|
|
ImGui::Text("Hello from another window!");
|
|
ImGui::ColorEdit3("Cube 1 Color", hud->cubeColor1);
|
|
ImGui::ColorEdit3("Cube 2 Color", hud->cubeColor2);
|
|
ImGui::SliderFloat("Rotation Speed", &hud->rotation_speed, 0.0f, 200.0f);
|
|
if (ImGui::Button("Close Me"))
|
|
hud->show_another_window = false;
|
|
ImGui::End();
|
|
}
|
|
|
|
// 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow(). Read its code to learn more about Dear ImGui!
|
|
if (hud->show_demo_window)
|
|
{
|
|
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
|
|
ImGui::ShowDemoWindow(&hud->show_demo_window);
|
|
}
|
|
}
|