main.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. // For imgui_impl_null: use relative filename + embed implementation directly by including the .cpp file.
  7. // This is to simplify casual building of this example from all sorts of test scripts.
  8. #include "../../backends/imgui_impl_null.h"
  9. #include "../../backends/imgui_impl_null.cpp"
  10. int main(int, char**)
  11. {
  12. IMGUI_CHECKVERSION();
  13. ImGui::CreateContext();
  14. ImGuiIO& io = ImGui::GetIO();
  15. ImGui_ImplNullPlatform_Init();
  16. ImGui_ImplNullRender_Init();
  17. for (int n = 0; n < 20; n++)
  18. {
  19. printf("NewFrame() %d\n", n);
  20. ImGui_ImplNullPlatform_NewFrame();
  21. ImGui_ImplNullRender_NewFrame();
  22. ImGui::NewFrame();
  23. static float f = 0.0f;
  24. ImGui::Text("Hello, world!");
  25. ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
  26. ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
  27. ImGui::ShowDemoWindow(nullptr);
  28. ImGui::Render();
  29. }
  30. printf("DestroyContext()\n");
  31. ImGui_ImplNullRender_Shutdown();
  32. ImGui_ImplNullPlatform_Shutdown();
  33. ImGui::DestroyContext();
  34. return 0;
  35. }