diff --git a/include/application.h b/include/application.h index fb4b133..40d0c33 100644 --- a/include/application.h +++ b/include/application.h @@ -14,84 +14,85 @@ namespace engine { -class Application { - public: - struct Configuration { - bool enable_frame_limiter; - }; - - const char* const app_name; - const char* const app_version; - - Application(const char* app_name, const char* app_version, gfx::GraphicsSettings graphics_settings, Configuration configuration); - ~Application(); - Application(const Application&) = delete; - Application& operator=(const Application&) = delete; - - /* resource stuff */ - - template - void RegisterResourceManager() - { - size_t hash = typeid(T).hash_code(); - assert(resource_managers_.contains(hash) == false && "Registering resource manager type more than once."); - resource_managers_.emplace(hash, std::make_unique>()); - } - - template - std::shared_ptr AddResource(const std::string& name, std::unique_ptr&& resource) - { - auto resource_manager = GetResourceManager(); - return resource_manager->Add(name, std::move(resource)); - } - - template - std::shared_ptr GetResource(const std::string& name) - { - auto resource_manager = GetResourceManager(); - return resource_manager->Get(name); - } - - /* methods */ - void GameLoop(); - - void SetFrameLimiter(bool on) { configuration_.enable_frame_limiter = on; } - - /* getters */ - Window* window() { return window_.get(); } - InputManager* input_manager() { return input_manager_.get(); } - SceneManager* scene_manager() { return scene_manager_.get(); } - Renderer* renderer() { return renderer_.get(); } - - std::string GetResourcePath(const std::string relative_path) const { return (resources_path_ / relative_path).string(); } - - std::vector debug_lines{}; - - private: - std::unique_ptr window_; - std::unique_ptr input_manager_; - std::unique_ptr renderer_; - std::unordered_map> resource_managers_{}; - std::filesystem::path resources_path_; - - // Most resources in the game are owned by component-lists found in scenes in this scene manager: - std::unique_ptr scene_manager_; - - Configuration configuration_; - - template - ResourceManager* GetResourceManager() - { - size_t hash = typeid(T).hash_code(); - auto it = resource_managers_.find(hash); - if (it == resource_managers_.end()) { - throw std::runtime_error("Cannot find resource manager."); - } - auto ptr = it->second.get(); - auto casted_ptr = dynamic_cast*>(ptr); - assert(casted_ptr != nullptr); - return casted_ptr; - } +struct AppConfiguration { + bool enable_frame_limiter; }; +class Application { +private: + std::unique_ptr m_window; + std::unique_ptr m_input_manager; + std::unique_ptr m_renderer; + std::unordered_map> m_resource_managers{}; + std::filesystem::path m_resources_path; + std::unique_ptr m_scene_manager; + AppConfiguration m_configuration; +public: + const char* const app_name; + const char* const app_version; + std::vector debug_lines{}; + +public: + Application(const char* app_name, const char* app_version, gfx::GraphicsSettings graphics_settings, AppConfiguration configuration); + Application(const Application&) = delete; + + ~Application(); + + Application& operator=(const Application&) = delete; + + template + void registerResourceManager(); + template + std::shared_ptr addResource(const std::string& name, std::unique_ptr&& resource); + template + std::shared_ptr getResource(const std::string& name); + void gameLoop(); + void setFrameLimiter(bool on) { m_configuration.enable_frame_limiter = on; } + Window* window() { return m_window.get(); } + InputManager* input_manager() { return m_input_manager.get(); } + SceneManager* scene_manager() { return m_scene_manager.get(); } + Renderer* renderer() { return m_renderer.get(); } + std::string getResourcePath(const std::string relative_path) const { return (m_resources_path / relative_path).string(); } + +private: + template + ResourceManager* getResourceManager(); +}; + +template +void Application::registerResourceManager() +{ + size_t hash = typeid(T).hash_code(); + assert(m_resource_managers.contains(hash) == false && "Registering resource manager type more than once."); + m_resource_managers.emplace(hash, std::make_unique>()); +} + +template +std::shared_ptr Application::addResource(const std::string& name, std::unique_ptr&& resource) +{ + auto resource_manager = getResourceManager(); + return resource_manager->Add(name, std::move(resource)); +} + +template +std::shared_ptr Application::getResource(const std::string& name) +{ + auto resource_manager = getResourceManager(); + return resource_manager->Get(name); +} + +template +ResourceManager* Application::getResourceManager() +{ + size_t hash = typeid(T).hash_code(); + auto it = m_resource_managers.find(hash); + if (it == m_resource_managers.end()) { + throw std::runtime_error("Cannot find resource manager."); + } + auto ptr = it->second.get(); + auto casted_ptr = dynamic_cast*>(ptr); + assert(casted_ptr != nullptr); + return casted_ptr; +} + } // namespace engine \ No newline at end of file diff --git a/src/application.cpp b/src/application.cpp index 4cb0d09..3e01087 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -53,33 +53,33 @@ static std::filesystem::path getResourcesPath() static auto frametimeFromFPS(int fps) { return std::chrono::nanoseconds(1'000'000'000 / fps); } -Application::Application(const char* appName, const char* appVersion, gfx::GraphicsSettings graphicsSettings, Configuration configuration) - : app_name(appName), app_version(appVersion), configuration_(configuration) +Application::Application(const char* appName, const char* appVersion, gfx::GraphicsSettings graphicsSettings, AppConfiguration configuration) + : app_name(appName), app_version(appVersion), m_configuration(configuration) { - window_ = std::make_unique(appName, true, false); - input_manager_ = std::make_unique(window_.get()); - scene_manager_ = std::make_unique(this); + m_window = std::make_unique(appName, true, false); + m_input_manager = std::make_unique(m_window.get()); + m_scene_manager = std::make_unique(this); // get base path for resources - resources_path_ = getResourcesPath(); + m_resources_path = getResourcesPath(); // register resource managers - RegisterResourceManager(); - RegisterResourceManager(); - RegisterResourceManager(); - RegisterResourceManager(); - RegisterResourceManager(); + registerResourceManager(); + registerResourceManager(); + registerResourceManager(); + registerResourceManager(); + registerResourceManager(); im_gui_things.context = ImGui::CreateContext(); // ImGuiIO& io = ImGui::GetIO() - ImGui_ImplSDL2_InitForVulkan(window_->GetHandle()); + ImGui_ImplSDL2_InitForVulkan(m_window->GetHandle()); - renderer_ = std::make_unique(*this, graphicsSettings); + m_renderer = std::make_unique(*this, graphicsSettings); /* default fonts */ { - auto monoFont = std::make_unique(GetResourcePath("engine/fonts/mono.ttf")); - GetResourceManager()->AddPersistent("builtin.mono", std::move(monoFont)); + auto monoFont = std::make_unique(getResourcePath("engine/fonts/mono.ttf")); + getResourceManager()->AddPersistent("builtin.mono", std::move(monoFont)); } /* default shaders */ @@ -95,8 +95,8 @@ Application::Application(const char* appName, const char* appVersion, gfx::Graph shaderSettings.write_z = true; shaderSettings.render_order = 0; auto fancyShader = - std::make_unique(renderer(), GetResourcePath("engine/shaders/fancy.vert"), GetResourcePath("engine/shaders/fancy.frag"), shaderSettings); - GetResourceManager()->AddPersistent("builtin.fancy", std::move(fancyShader)); + std::make_unique(renderer(), getResourcePath("engine/shaders/fancy.vert"), getResourcePath("engine/shaders/fancy.frag"), shaderSettings); + getResourceManager()->AddPersistent("builtin.fancy", std::move(fancyShader)); } /* default textures */ @@ -108,7 +108,7 @@ Application::Application(const char* appName, const char* appVersion, gfx::Graph samplerInfo.mipmap = gfx::Filter::kNearest; samplerInfo.anisotropic_filtering = false; auto whiteTexture = std::make_unique(renderer(), pixel, 1, 1, samplerInfo, true); - GetResourceManager()->AddPersistent("builtin.white", std::move(whiteTexture)); + getResourceManager()->AddPersistent("builtin.white", std::move(whiteTexture)); } { const uint8_t pixel[4] = {0, 0, 0, 255}; @@ -118,7 +118,7 @@ Application::Application(const char* appName, const char* appVersion, gfx::Graph samplerInfo.mipmap = gfx::Filter::kNearest; samplerInfo.anisotropic_filtering = false; auto blackTexture = std::make_unique(renderer(), pixel, 1, 1, samplerInfo, true); - GetResourceManager()->AddPersistent("builtin.black", std::move(blackTexture)); + getResourceManager()->AddPersistent("builtin.black", std::move(blackTexture)); } { const uint8_t pixel[4] = {127, 127, 255, 255}; @@ -128,7 +128,7 @@ Application::Application(const char* appName, const char* appVersion, gfx::Graph samplerInfo.mipmap = gfx::Filter::kNearest; samplerInfo.anisotropic_filtering = false; auto normalTexture = std::make_unique(renderer(), pixel, 1, 1, samplerInfo, false); - GetResourceManager()->AddPersistent("builtin.normal", std::move(normalTexture)); + getResourceManager()->AddPersistent("builtin.normal", std::move(normalTexture)); } { const uint8_t pixel[4] = {255, 127, 0, 255}; // AO, roughness, metallic @@ -138,31 +138,31 @@ Application::Application(const char* appName, const char* appVersion, gfx::Graph samplerInfo.mipmap = gfx::Filter::kNearest; samplerInfo.anisotropic_filtering = false; auto mrTexture = std::make_unique(renderer(), pixel, 1, 1, samplerInfo, false); - GetResourceManager()->AddPersistent("builtin.mr", std::move(mrTexture)); + getResourceManager()->AddPersistent("builtin.mr", std::move(mrTexture)); } /* default materials */ { - auto defaultMaterial = std::make_unique(renderer(), GetResource("builtin.fancy")); - defaultMaterial->setAlbedoTexture(GetResource("builtin.white")); - defaultMaterial->setNormalTexture(GetResource("builtin.normal")); - defaultMaterial->setOcclusionRoughnessMetallicTexture(GetResource("builtin.mr")); - GetResourceManager()->AddPersistent("builtin.default", std::move(defaultMaterial)); + auto defaultMaterial = std::make_unique(renderer(), getResource("builtin.fancy")); + defaultMaterial->setAlbedoTexture(getResource("builtin.white")); + defaultMaterial->setNormalTexture(getResource("builtin.normal")); + defaultMaterial->setOcclusionRoughnessMetallicTexture(getResource("builtin.mr")); + getResourceManager()->AddPersistent("builtin.default", std::move(defaultMaterial)); } } Application::~Application() { - renderer_->GetDevice()->ShutdownImguiBackend(); + m_renderer->GetDevice()->ShutdownImguiBackend(); ImGui_ImplSDL2_Shutdown(); ImGui::DestroyContext(im_gui_things.context); } -void Application::GameLoop() +void Application::gameLoop() { LOG_DEBUG("Begin game loop..."); - auto lastTick = window_->GetNanos(); + auto lastTick = m_window->GetNanos(); std::array delta_times{}; struct DebugMenuState { @@ -174,8 +174,8 @@ void Application::GameLoop() bool vsync = false; bool show_info_window = false; } debug_menu_state; - debug_menu_state.enable_frame_limiter = configuration_.enable_frame_limiter; - switch (renderer_->GetDevice()->GetPresentMode()) { + debug_menu_state.enable_frame_limiter = m_configuration.enable_frame_limiter; + switch (m_renderer->GetDevice()->GetPresentMode()) { case gfx::PresentMode::kDoubleBufferedNoVsync: debug_menu_state.triple_buffering = false; debug_menu_state.vsync = false; @@ -194,32 +194,32 @@ void Application::GameLoop() auto endFrame = beginFrame + frametimeFromFPS(fps_limit); // single-threaded game loop - while (window_->IsRunning()) { + while (m_window->IsRunning()) { /* logic */ const float avg_fps = static_cast(delta_times.size()) / std::accumulate(delta_times.begin(), delta_times.end(), 0.0f); - Scene* scene = scene_manager_->UpdateActiveScene(window_->dt()); + Scene* scene = m_scene_manager->UpdateActiveScene(m_window->dt()); - uint64_t now = window_->GetNanos(); + uint64_t now = m_window->GetNanos(); if (now - lastTick >= 1000000000LL * 5LL) [[unlikely]] { lastTick = now; LOG_DEBUG("fps: {}", std::lroundf(avg_fps)); renderer()->GetDevice()->LogPerformanceInfo(); - window_->ResetAvgFPS(); + m_window->ResetAvgFPS(); } - if (window_->GetKeyPress(inputs::Key::K_F5)) { - bool show_window = window_->MouseCaptured(); + if (m_window->GetKeyPress(inputs::Key::K_F5)) { + bool show_window = m_window->MouseCaptured(); debug_menu_state.menu_active = show_window; - window_->SetRelativeMouseMode(!show_window); + m_window->SetRelativeMouseMode(!show_window); } - if (window_->GetKeyPress(inputs::Key::K_F6)) { + if (m_window->GetKeyPress(inputs::Key::K_F6)) { debug_menu_state.show_info_window = !debug_menu_state.show_info_window; } - if (window_->GetKeyPress(inputs::Key::K_L)) { + if (m_window->GetKeyPress(inputs::Key::K_L)) { debug_menu_state.enable_frame_limiter ^= true; } @@ -230,7 +230,7 @@ void Application::GameLoop() //ImGui::ShowDemoWindow(); // Stop mouse from moving the camera when the settings menu is open - input_manager_->SetDeviceActive(InputDevice::kMouse, !debug_menu_state.menu_active); + m_input_manager->SetDeviceActive(InputDevice::kMouse, !debug_menu_state.menu_active); if (debug_menu_state.menu_active) { if (ImGui::Begin("Settings", 0)) { @@ -244,10 +244,10 @@ void Application::GameLoop() } if (ImGui::Checkbox("Enable vsync", &debug_menu_state.vsync)) { if (debug_menu_state.vsync) { - renderer_->GetDevice()->ChangePresentMode(gfx::PresentMode::kDoubleBufferedVsync); + m_renderer->GetDevice()->ChangePresentMode(gfx::PresentMode::kDoubleBufferedVsync); } else { - renderer_->GetDevice()->ChangePresentMode(gfx::PresentMode::kDoubleBufferedNoVsync); + m_renderer->GetDevice()->ChangePresentMode(gfx::PresentMode::kDoubleBufferedNoVsync); } } if (debug_menu_state.triple_buffering) { @@ -256,14 +256,14 @@ void Application::GameLoop() if (ImGui::Checkbox("Triple buffering", &debug_menu_state.triple_buffering)) { if (debug_menu_state.triple_buffering) { debug_menu_state.vsync = false; - renderer_->GetDevice()->ChangePresentMode(gfx::PresentMode::kTripleBuffered); + m_renderer->GetDevice()->ChangePresentMode(gfx::PresentMode::kTripleBuffered); } else { if (debug_menu_state.vsync) { - renderer_->GetDevice()->ChangePresentMode(gfx::PresentMode::kDoubleBufferedVsync); + m_renderer->GetDevice()->ChangePresentMode(gfx::PresentMode::kDoubleBufferedVsync); } else { - renderer_->GetDevice()->ChangePresentMode(gfx::PresentMode::kDoubleBufferedNoVsync); + m_renderer->GetDevice()->ChangePresentMode(gfx::PresentMode::kDoubleBufferedNoVsync); } } } @@ -506,33 +506,33 @@ void Application::GameLoop() static_list = mesh_render_system->GetStaticRenderList(); dynamic_list = mesh_render_system->GetDynamicRenderList(); } - renderer_->Render(window()->GetWindowResized(), camera_transform, static_list, dynamic_list, debug_lines); + m_renderer->Render(window()->GetWindowResized(), camera_transform, static_list, dynamic_list, debug_lines); debug_lines.clear(); // gets remade every frame :0 /* poll events */ - window_->GetInputAndEvents(); + m_window->GetInputAndEvents(); /* fps limiter */ - if (configuration_.enable_frame_limiter != debug_menu_state.enable_frame_limiter) { + if (m_configuration.enable_frame_limiter != debug_menu_state.enable_frame_limiter) { if (debug_menu_state.enable_frame_limiter) { - configuration_.enable_frame_limiter = true; + m_configuration.enable_frame_limiter = true; // reset beginFrame and endFrame so the limiter doesn't hang for ages beginFrame = std::chrono::steady_clock::now(); endFrame = beginFrame; } else { - configuration_.enable_frame_limiter = false; + m_configuration.enable_frame_limiter = false; } } - if (configuration_.enable_frame_limiter) { + if (m_configuration.enable_frame_limiter) { std::this_thread::sleep_until(endFrame); } beginFrame = endFrame; endFrame = beginFrame + frametimeFromFPS(fps_limit); - delta_times[window_->GetFrameCount() % delta_times.size()] = window_->dt(); + delta_times[m_window->GetFrameCount() % delta_times.size()] = m_window->dt(); } - renderer_->GetDevice()->WaitIdle(); + m_renderer->GetDevice()->WaitIdle(); } } // namespace engine diff --git a/src/application_component.cpp b/src/application_component.cpp index 158075e..36b2c4c 100644 --- a/src/application_component.cpp +++ b/src/application_component.cpp @@ -7,7 +7,7 @@ namespace engine { -std::string ApplicationComponent::GetResourcePath(const std::string& relative_path) const { return app_.GetResourcePath(relative_path); } +std::string ApplicationComponent::GetResourcePath(const std::string& relative_path) const { return app_.getResourcePath(relative_path); } SDL_Window* ApplicationComponent::GetWindowHandle() const { return app_.window()->GetHandle(); diff --git a/src/gltf_loader.cpp b/src/gltf_loader.cpp index 5745437..c02ed25 100644 --- a/src/gltf_loader.cpp +++ b/src/gltf_loader.cpp @@ -150,7 +150,7 @@ engine::Entity LoadGLTF(Scene& scene, const std::string& path, bool isStatic) for (const tg::Texture& texture : model.textures) { // find the image first // use missing texture image by default - textures.emplace_back(scene.app()->GetResource("builtin.white")); + textures.emplace_back(scene.app()->getResource("builtin.white")); if (texture.source == -1) { LOG_ERROR("A gltf file specifies a texture with no source."); @@ -245,10 +245,10 @@ engine::Entity LoadGLTF(Scene& scene, const std::string& path, bool isStatic) } } - materials.emplace_back(std::make_shared(scene.app()->renderer(), scene.app()->GetResource("builtin.fancy"))); + materials.emplace_back(std::make_shared(scene.app()->renderer(), scene.app()->getResource("builtin.fancy"))); // base color - materials.back()->setAlbedoTexture(scene.app()->GetResource("builtin.white")); + materials.back()->setAlbedoTexture(scene.app()->getResource("builtin.white")); if (material.pbrMetallicRoughness.baseColorTexture.index != -1) { if (material.pbrMetallicRoughness.baseColorTexture.texCoord == 0) { materials.back()->setAlbedoTexture(textures.at(material.pbrMetallicRoughness.baseColorTexture.index)); @@ -274,7 +274,7 @@ engine::Entity LoadGLTF(Scene& scene, const std::string& path, bool isStatic) // occlusion roughness metallic materials.back()->setOcclusionRoughnessMetallicTexture( - scene.app()->GetResource("builtin.white")); // default ao = 1.0, rough = 1.0, metal = 1.0 + scene.app()->getResource("builtin.white")); // default ao = 1.0, rough = 1.0, metal = 1.0 if (material.pbrMetallicRoughness.metallicRoughnessTexture.index != -1) { if (material.pbrMetallicRoughness.metallicRoughnessTexture.texCoord == 0) { LOG_DEBUG("Setting occlusion roughness metallic texture!"); @@ -316,7 +316,7 @@ engine::Entity LoadGLTF(Scene& scene, const std::string& path, bool isStatic) } // normal map - materials.back()->setNormalTexture(scene.app()->GetResource("builtin.normal")); + materials.back()->setNormalTexture(scene.app()->getResource("builtin.normal")); if (material.normalTexture.index != -1) { if (material.normalTexture.texCoord == 0) { materials.back()->setNormalTexture(textures.at(material.normalTexture.index)); @@ -558,7 +558,7 @@ engine::Entity LoadGLTF(Scene& scene, const std::string& path, bool isStatic) engine_material = materials.at(primitive.material); } else { - engine_material = scene.app()->GetResource("builtin.default"); + engine_material = scene.app()->getResource("builtin.default"); } // get AABB diff --git a/test/src/game.cpp b/test/src/game.cpp index 26a6444..fa8a208 100644 --- a/test/src/game.cpp +++ b/test/src/game.cpp @@ -50,7 +50,7 @@ void PlayGame(GameSettings settings) graphics_settings.msaa_level = engine::gfx::MSAALevel::kOff; graphics_settings.enable_anisotropy = true; - engine::Application::Configuration configuration{}; + engine::AppConfiguration configuration{}; configuration.enable_frame_limiter = settings.enable_frame_limiter; engine::Application app(PROJECT_NAME, PROJECT_VERSION, graphics_settings, configuration); @@ -83,7 +83,7 @@ void PlayGame(GameSettings settings) auto camren = main_scene->AddComponent(camera_child); camren->visible = false; camren->mesh = GenSphereMesh(app.renderer()->GetDevice(), 1.0f, /*16*/32); - camren->material = app.GetResource("builtin.default"); + camren->material = app.getResource("builtin.default"); /* as of right now, the entity with tag 'camera' is used to build the view * matrix */ @@ -97,45 +97,45 @@ void PlayGame(GameSettings settings) main_scene->AddComponent(camera); /* floor */ - engine::Entity floor = engine::util::LoadGLTF(*main_scene, app.GetResourcePath("models/floor2.glb"), true); + engine::Entity floor = engine::util::LoadGLTF(*main_scene, app.getResourcePath("models/floor2.glb"), true); //main_scene->GetComponent(main_scene->GetEntity("Cube", floor))->visible = false; - engine::Entity monke = engine::util::LoadGLTF(*main_scene, app.GetResourcePath("models/monke.glb"), true); + engine::Entity monke = engine::util::LoadGLTF(*main_scene, app.getResourcePath("models/monke.glb"), true); main_scene->GetComponent(monke)->position.y += 10.0f; - // engine::Entity bottle = engine::util::LoadGLTF(*main_scene, app.GetResourcePath("models/bottle.glb")); + // engine::Entity bottle = engine::util::LoadGLTF(*main_scene, app.getResourcePath("models/bottle.glb")); // main_scene->GetComponent(bottle)->scale *= 10.0f; // main_scene->GetComponent(bottle)->position.x += 25.0f; // main_scene->GetComponent(bottle)->position.z += 5.0f; - engine::Entity helmet = engine::util::LoadGLTF(*main_scene, app.GetResourcePath("models/DamagedHelmet.glb"), true); + engine::Entity helmet = engine::util::LoadGLTF(*main_scene, app.getResourcePath("models/DamagedHelmet.glb"), true); main_scene->GetPosition(helmet) += glm::vec3{5.0f, 5.0f, 5.0f}; main_scene->GetScale(helmet) *= 3.0f; main_scene->GetRotation(helmet) = glm::angleAxis(glm::pi(), glm::vec3{ 0.0f, 0.0f, 1.0f }); main_scene->GetRotation(helmet) *= glm::angleAxis(glm::half_pi(), glm::vec3{ 1.0f, 0.0f, 0.0f }); - engine::Entity toycar = engine::util::LoadGLTF(*main_scene, app.GetResourcePath("models/ToyCar.glb"), true); + engine::Entity toycar = engine::util::LoadGLTF(*main_scene, app.getResourcePath("models/ToyCar.glb"), true); main_scene->GetScale(toycar) *= 150.0f; main_scene->GetPosition(toycar).z -= 0.07f; - engine::Entity stairs = engine::util::LoadGLTF(*main_scene, app.GetResourcePath("models/stairs.glb"), true); + engine::Entity stairs = engine::util::LoadGLTF(*main_scene, app.getResourcePath("models/stairs.glb"), true); main_scene->GetPosition(stairs) += glm::vec3{-8.0f, -5.0f, 0.1f}; main_scene->GetRotation(stairs) = glm::angleAxis(glm::half_pi(), glm::vec3{0.0f, 0.0f, 1.0f}); main_scene->GetRotation(stairs) *= glm::angleAxis(glm::half_pi(), glm::vec3{1.0f, 0.0f, 0.0f}); - engine::Entity axes = engine::util::LoadGLTF(*main_scene, app.GetResourcePath("models/MY_AXES.glb"), true); + engine::Entity axes = engine::util::LoadGLTF(*main_scene, app.getResourcePath("models/MY_AXES.glb"), true); main_scene->GetPosition(axes) += glm::vec3{-40.0f, -40.0f, 1.0f}; - engine::Entity bottle = engine::util::LoadGLTF(*main_scene, app.GetResourcePath("models/bottle.glb"), true); + engine::Entity bottle = engine::util::LoadGLTF(*main_scene, app.getResourcePath("models/bottle.glb"), true); main_scene->GetPosition(bottle).y -= 10.0f; main_scene->GetPosition(bottle).z += 2.5f; main_scene->GetScale(bottle) *= 25.0f; - //engine::Entity cube = engine::util::LoadGLTF(*main_scene, app.GetResourcePath("models/cube.glb"), false); + //engine::Entity cube = engine::util::LoadGLTF(*main_scene, app.getResourcePath("models/cube.glb"), false); engine::Entity cube = main_scene->CreateEntity("cube", 0, glm::vec3{ 4.0f, -17.0f, 0.0f }); main_scene->GetTransform(cube)->is_static = false; auto cube_ren = main_scene->AddComponent(cube); - cube_ren->material = app.GetResource("builtin.default"); + cube_ren->material = app.getResource("builtin.default"); cube_ren->mesh = GenCuboidMesh(app.renderer()->GetDevice(), 1.0f, 1.0f, 1.0f); cube_ren->visible = true; auto cubeCustom = main_scene->AddComponent(cube); @@ -148,15 +148,15 @@ void PlayGame(GameSettings settings) }; - engine::Entity teapot = engine::util::LoadGLTF(*main_scene, app.GetResourcePath("models/teapot.glb"), true); + engine::Entity teapot = engine::util::LoadGLTF(*main_scene, app.getResourcePath("models/teapot.glb"), true); main_scene->GetPosition(teapot).y += 5.0f; main_scene->GetPosition(teapot).x -= 5.0f; main_scene->GetScale(teapot) *= 5.0f; - engine::Entity tree = engine::util::LoadGLTF(*main_scene, app.GetResourcePath("models/tree.glb"), true); + engine::Entity tree = engine::util::LoadGLTF(*main_scene, app.getResourcePath("models/tree.glb"), true); main_scene->GetPosition(tree) = glm::vec3{-5.0f, -5.0f, 0.0f}; - engine::Entity box = engine::util::LoadGLTF(*main_scene, app.GetResourcePath("models/box.glb"), true); + engine::Entity box = engine::util::LoadGLTF(*main_scene, app.getResourcePath("models/box.glb"), true); main_scene->GetPosition(box) = glm::vec3{ -5.0f, -17.0f, 0.1f }; main_scene->GetScale(box) *= 10.0f; main_scene->GetRotation(box) = glm::angleAxis(glm::pi() * 0.0f, glm::vec3{ 0.0f, 0.0f, 1.0f }); @@ -167,5 +167,5 @@ void PlayGame(GameSettings settings) main_scene->GetSystem()->next_scene_ = start_scene; app.scene_manager()->SetActiveScene(main_scene); - app.GameLoop(); + app.gameLoop(); }