#include #include // services #include #include #include #include #include #include #include #include #include const char* argv0; using namespace entt::literals; TEST(imgui_widgets, basic) { MM::Engine engine; auto& sdl_ss = engine.addService(); ASSERT_TRUE(engine.enableService()); sdl_ss.createGLWindow("imgui_widget_test", 1280, 720); engine.addService(argv0, "imgui_widget_test"); ASSERT_TRUE(engine.enableService()); engine.addService(); ASSERT_TRUE(engine.enableService()); auto& rs = engine.addService(); ASSERT_TRUE(engine.enableService()); rs.addRenderTask(engine); class TestWindow : public MM::Services::Service { public: const char* name(void) override { return "TestWindow"; } bool enable(MM::Engine&, std::vector& task_array) override { task_array.push_back( MM::UpdateStrategies::TaskInfo{"testwindow"} .fn([](MM::Engine&) { if (ImGui::Begin("test window")) { static float knob_test = 0.f; MM::ImGuiWidgets::KnobFloat("knob1", &knob_test, 0.f, 1.f); ImGui::SameLine(); MM::ImGuiWidgets::KnobFloat("knob2", &knob_test, 0.f, 1.f, 0.f, false); static MM::ScalarRange2 range {0, 100}; MM::ImGuiWidgets::DragScalarRange2("range", range); } ImGui::End(); }) ); return true; } void disable(MM::Engine&) override {} }; engine.addService(); ASSERT_TRUE(engine.enableService()); #ifdef MM_AUTOTEST engine.addService(50); // 50 frames ASSERT_TRUE(engine.enableService()); #endif engine.run(); sdl_ss.destroyWindow(); } int main(int argc, char** argv) { argv0 = argv[0]; ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }