MCPcopy Create free account
hub / github.com/VictorGordan/opengl-tutorials / ShowExampleAppLog

Function ShowExampleAppLog

ImGUI GLFW Tutorial/imgui/imgui_demo.cpp:6744–6771  ·  view source on GitHub ↗

Demonstrate creating a simple log window with basic filtering.

Source from the content-addressed store, hash-verified

6742
6743// Demonstrate creating a simple log window with basic filtering.
6744static void ShowExampleAppLog(bool* p_open)
6745{
6746 static ExampleAppLog log;
6747
6748 // For the demo: add a debug button _BEFORE_ the normal log window contents
6749 // We take advantage of a rarely used feature: multiple calls to Begin()/End() are appending to the _same_ window.
6750 // Most of the contents of the window will be added by the log.Draw() call.
6751 ImGui::SetNextWindowSize(ImVec2(500, 400), ImGuiCond_FirstUseEver);
6752 ImGui::Begin("Example: Log", p_open);
6753 if (ImGui::SmallButton("[Debug] Add 5 entries"))
6754 {
6755 static int counter = 0;
6756 const char* categories[3] = { "info", "warn", "error" };
6757 const char* words[] = { "Bumfuzzled", "Cattywampus", "Snickersnee", "Abibliophobia", "Absquatulate", "Nincompoop", "Pauciloquent" };
6758 for (int n = 0; n < 5; n++)
6759 {
6760 const char* category = categories[counter % IM_ARRAYSIZE(categories)];
6761 const char* word = words[counter % IM_ARRAYSIZE(words)];
6762 log.AddLog("[%05d] [%s] Hello, current time is %.1f, here's a word: '%s'\n",
6763 ImGui::GetFrameCount(), category, ImGui::GetTime(), word);
6764 counter++;
6765 }
6766 }
6767 ImGui::End();
6768
6769 // Actually call in the regular Log helper (which will Begin() into the same window as we just did)
6770 log.Draw("Example: Log", p_open);
6771}
6772
6773//-----------------------------------------------------------------------------
6774// [SECTION] Example App: Simple Layout / ShowExampleAppLayout()

Callers 1

ShowDemoWindowMethod · 0.85

Calls 2

ImVec2Function · 0.70
DrawMethod · 0.45

Tested by

no test coverage detected