mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-07 15:05:47 +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/.
39 lines
1.0 KiB
C++
39 lines
1.0 KiB
C++
// dear imgui: run test for the C++20 backend module 'imgui.impl.null' (see backends/imgui_impl_null.cppm).
|
|
// Differential test (see test_diff.h): the header build (IMGUI_TEST_HEADER) and the module build must print the same output.
|
|
|
|
#ifdef IMGUI_TEST_HEADER
|
|
#include "imgui.h"
|
|
#include "imgui_impl_null.h"
|
|
#include <stdio.h>
|
|
#else
|
|
import std.compat;
|
|
import imgui;
|
|
import imgui.impl.null;
|
|
#endif
|
|
#include "test_diff.h"
|
|
|
|
int main()
|
|
{
|
|
ImGui::CreateContext();
|
|
TestDiff_Init();
|
|
if (!ImGui_ImplNull_Init())
|
|
return 1;
|
|
|
|
TestHash hash;
|
|
for (int frame = 0; frame < TestDiff_FrameCount; frame++)
|
|
{
|
|
ImGui_ImplNull_NewFrame();
|
|
TestDiff_NewFrame(frame);
|
|
ImGui::NewFrame();
|
|
TestDiff_ShowWindows();
|
|
ImGui::Render();
|
|
TestDiff_HashDrawData(hash, ImGui::GetDrawData());
|
|
ImGui_ImplNullRender_RenderDrawData(ImGui::GetDrawData());
|
|
}
|
|
|
|
ImGui_ImplNull_Shutdown();
|
|
ImGui::DestroyContext();
|
|
hash.Print("imgui.impl.null");
|
|
return hash.VtxCount > 0 ? 0 : 1;
|
|
}
|