mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-06 06:25:54 +01:00
Module support is easy to break from the header side, e.g. by a new system include, a forward-declared platform type, or an export block that misses a declaration. This adds a CMake project that builds every module whose platform library is found, alongside the header build of the same code. Linking alone doesn't show that the module behaves like the headers, so the main check is differential. 'DIFF' tests are compiled once with 'import imgui;' and once with '#include "imgui.h"'. Both builds run the same scripted frames and must print the same hash of the draw data and texture uploads (test_diff.h, compare_output.cmake). Backends that need a GPU or a display are only linked, and wgpu is only compiled. The core module and the null backend are also built for each compile-time configuration that CI builds example_null with, because IMGUI_DISABLE_* and friends change what gets exported. Presets use Clang, Ninja and 'import std'. Toolchains for cross builds belong in CMakeUserPresets.json, which is ignored along with build/.
32 lines
1.2 KiB
C++
32 lines
1.2 KiB
C++
// dear imgui: header-only (non-module) test for imgui_internal.h.
|
|
// imgui_internal.h must work on its own, including after imgui_macros.h (which defines IMGUI_VERSION without the declarations of imgui.h).
|
|
|
|
#include "imgui_macros.h"
|
|
#include "imgui_internal.h"
|
|
#include <stdio.h>
|
|
|
|
int main()
|
|
{
|
|
IMGUI_CHECKVERSION();
|
|
ImGuiContext* ctx = ImGui::CreateContext();
|
|
ImGuiIO& io = ImGui::GetIO(ctx); // imgui_internal.h API
|
|
io.DisplaySize = ImVec2(1280.0f, 720.0f);
|
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // (no renderer: textures are never uploaded)
|
|
|
|
ImGuiWindow* window = nullptr;
|
|
for (int frame = 0; frame < 2; frame++) // new windows are hidden on their first frame
|
|
{
|
|
ImGui::NewFrame();
|
|
ImGui::Begin("Test");
|
|
window = ImGui::GetCurrentWindow();
|
|
ImGui::Text("Hello");
|
|
ImGui::End();
|
|
ImGui::Render();
|
|
}
|
|
|
|
const bool ok = window != nullptr && ImGui::GetDrawData()->TotalVtxCount > 0 && ctx->FrameCount == 2;
|
|
printf("window=%p vtx=%d frame=%d\n", (void*)window, ImGui::GetDrawData()->TotalVtxCount, ctx->FrameCount);
|
|
ImGui::DestroyContext(ctx);
|
|
return ok ? 0 : 1;
|
|
}
|