adopt engine stuff to new update strategy

This commit is contained in:
2020-12-26 19:29:39 +01:00
parent c1ae30c89c
commit 840b663d5e
28 changed files with 351 additions and 324 deletions

View File

@ -116,11 +116,11 @@ TEST(blur_render_task, it) {
for (int i = 0; i < 10; i++) {
auto e = scene.create();
auto& t = scene.emplace<MM::Components::Transform2D>(e);
t.position.x = i * 9.f - 40;
t.position.x = float(i) * 9.f - 40.f;
t.scale = {5,5};
auto& v = scene.emplace<MM::Components::Velocity2D>(e);
v.rotation = i * 0.3f;
v.rotation = float(i) * 0.3f;
if (mt() % 2) {
auto& col = scene.emplace<MM::Components::Color>(e);
@ -132,12 +132,6 @@ TEST(blur_render_task, it) {
}
engine.addUpdate(
[&](MM::Engine&) {
ImGui::ColorEdit4("rect_col", &bsrr_rend.default_color[0]);
}
);
engine.run();
}

View File

@ -1,3 +1,4 @@
#include "mm/services/service.hpp"
#include <gtest/gtest.h>
#include <mm/engine.hpp>
@ -7,6 +8,8 @@
#include <mm/services/imgui_s.hpp>
#include <mm/opengl/render_tasks/imgui.hpp>
#include <entt/core/hashed_string.hpp>
#include <imgui/imgui.h>
TEST(imgui_render_task, demowindow) {
@ -22,19 +25,26 @@ TEST(imgui_render_task, demowindow) {
engine.addService<MM::Services::ImGuiService>();
ASSERT_TRUE(engine.enableService<MM::Services::ImGuiService>());
class ImGuiDemoWindowService : public MM::Services::Service {
public:
const char* name(void) override { return "ImGuiDemoWindowService"; }
bool enable(MM::Engine&) override { return true; }
void disable(MM::Engine&) override {}
std::vector<MM::UpdateStrategies::UpdateCreationInfo> registerUpdates(void) override {
return {{
"ImGuiDemoWindow"_hs,
"ImGuiDemoWindow",
[](MM::Engine&) { ImGui::ShowDemoWindow(); }
}};
}
};
engine.addService<ImGuiDemoWindowService>();
ASSERT_TRUE(engine.enableService<ImGuiDemoWindowService>());
rs.addRenderTask<MM::OpenGL::RenderTasks::ImGuiRT>(engine);
auto handle = engine.addUpdate([](MM::Engine&) {
ImGui::ShowDemoWindow();
}
);
{
auto tmp_lock = handle.lock();
tmp_lock->priority = 0;
tmp_lock->name = "imgui demo window";
}
engine.run();
}