1.3 KB、43行 生 Blame 履歴
1// dear imgui: "null" example application
2// (compile and link imgui, create context, run headless with NO INPUTS, NO GRAPHICS OUTPUT)
3// This is useful to test building, but you cannot interact with anything here!
4#include "imgui.h"
5#include <stdio.h>
6
7// For imgui_impl_null: use relative filename + embed implementation directly by including the .cpp file.
8// This is to simplify casual building of this example from all sorts of test scripts.
9#include "../../backends/imgui_impl_null.h"
10#include "../../backends/imgui_impl_null.cpp"
11
12int main(int, char**)
13{
14 IMGUI_CHECKVERSION();
15
16 ImGui::CreateContext();
17 ImGuiIO& io = ImGui::GetIO();
18
19 ImGui_ImplNullPlatform_Init();
20 ImGui_ImplNullRender_Init();
21
22 for (int n = 0; n < 20; n++)
23 {
24 printf("NewFrame() %d\n", n);
25 ImGui_ImplNullPlatform_NewFrame();
26 ImGui_ImplNullRender_NewFrame();
27 ImGui::NewFrame();
28
29 static float f = 0.0f;
30 ImGui::Text("Hello, world!");
31 ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
32 ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
33 ImGui::ShowDemoWindow(nullptr);
34
35 ImGui::Render();
36 }
37
38 printf("DestroyContext()\n");
39 ImGui_ImplNullRender_Shutdown();
40 ImGui_ImplNullPlatform_Shutdown();
41 ImGui::DestroyContext();
42 return 0;
43}