#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static char* argv0; using namespace entt::literals; class TemplateUpdateMainService : public MM::Services::Service { std::function _fn; public: explicit TemplateUpdateMainService(std::function fn) : _fn(fn) {} const char* name(void) override { return "TemplateUpdateMainService"; } bool enable(MM::Engine&, std::vector& task_array) override { task_array.push_back( MM::UpdateStrategies::TaskInfo{"TemplateUpdateMainService::fn"} .fn(_fn) ); return true; } void disable(MM::Engine&) override {} }; TEST(imgui_text_edit, it) { MM::Engine engine; auto& sdl_ss = engine.addService(SDL_INIT_VIDEO); ASSERT_TRUE(engine.enableService()); sdl_ss.createGLWindow("imgui_text_edit_test", 1280, 720); engine.addService(argv0, "imgui_text_edit_test"); ASSERT_TRUE(engine.enableService()); engine.addService(); ASSERT_TRUE(engine.enableService()); engine.addService(); ASSERT_TRUE(engine.enableService()); engine.addService(); ASSERT_TRUE(engine.enableService()); auto& rs = engine.addService(); ASSERT_TRUE(engine.enableService()); rs.addRenderTask(engine); engine.addService([](MM::Engine& e) { static MM::FileTextEditor fte{e}; fte.renderImGui(); }); ASSERT_TRUE(engine.enableService()); #ifdef MM_AUTOTEST engine.addService(50); // 50 frames ASSERT_TRUE(engine.enableService()); #endif engine.run(); // TODO: clear asset manager sdl_ss.destroyWindow(); } TEST(imgui_text_edit, shader) { MM::Engine engine; auto& sdl_ss = engine.addService(SDL_INIT_VIDEO); ASSERT_TRUE(engine.enableService()); sdl_ss.createGLWindow("imgui_text_edit_test", 1280, 720); engine.addService(argv0, "imgui_text_edit_test"); ASSERT_TRUE(engine.enableService()); engine.addService(); ASSERT_TRUE(engine.enableService()); engine.addService(); ASSERT_TRUE(engine.enableService()); engine.addService(); ASSERT_TRUE(engine.enableService()); auto& rs = engine.addService(); ASSERT_TRUE(engine.enableService()); rs.addRenderTask(engine); MM::FileTextEditor fte{engine}; MM::FileShaderEditor fse{engine}; engine.addService([&](MM::Engine&) { fte.renderImGui(); fse.renderImGui(); }); ASSERT_TRUE(engine.enableService()); #ifdef MM_AUTOTEST engine.addService(50); // 50 frames ASSERT_TRUE(engine.enableService()); #endif // TODO: fix non existant files fte.open("shader/quad_renderer/vert.glsl"); fse.open("shader/quad_renderer/frag.glsl"); // TODO: a shader to display plx engine.run(); // TODO: clear asset manager sdl_ss.destroyWindow(); } int main(int argc, char** argv) { argv0 = argv[0]; ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }