diff --git a/include/resources/texture.hpp b/include/resources/texture.hpp index acfd735..dab3173 100644 --- a/include/resources/texture.hpp +++ b/include/resources/texture.hpp @@ -20,7 +20,7 @@ public: ANISOTROPIC, }; - Texture(RenderData& renderData, const std::string& path, Filtering filtering); + Texture(RenderData* renderData, const std::string& path, Filtering filtering); ~Texture(); Texture(const Texture&) = delete; Texture& operator=(const Texture&) = delete; diff --git a/src/application.cpp b/src/application.cpp index c54fbbb..6ffdd2d 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -143,7 +143,7 @@ namespace engine { } { auto whiteTexture = std::make_unique( - renderData, + &renderData, getResourcePath("engine/textures/white.png"), resources::Texture::Filtering::OFF ); diff --git a/src/resources/texture.cpp b/src/resources/texture.cpp index bf7e35d..896b6b9 100644 --- a/src/resources/texture.cpp +++ b/src/resources/texture.cpp @@ -8,8 +8,8 @@ namespace engine::resources { -Texture::Texture(RenderData& renderData, const std::string& path, Filtering filtering) - : m_gfxDevice(renderData.gfxdev.get()) +Texture::Texture(RenderData* renderData, const std::string& path, Filtering filtering) + : m_gfxDevice(renderData->gfxdev.get()) { int width, height; @@ -41,13 +41,13 @@ Texture::Texture(RenderData& renderData, const std::string& path, Filtering filt samplerInfo.anisotropicFiltering = true; } - if (renderData.samplers.contains(samplerInfo) == false) { - renderData.samplers.insert(std::make_pair(samplerInfo, m_gfxDevice->createSampler(samplerInfo))); + if (renderData->samplers.contains(samplerInfo) == false) { + renderData->samplers.insert(std::make_pair(samplerInfo, m_gfxDevice->createSampler(samplerInfo))); } m_image = m_gfxDevice->createImage(width, height, texbuf->data()); - m_descriptorSet = m_gfxDevice->allocateDescriptorSet(renderData.materialSetLayout); - m_gfxDevice->updateDescriptorCombinedImageSampler(m_descriptorSet, 0, m_image, renderData.samplers.at(samplerInfo)); + m_descriptorSet = m_gfxDevice->allocateDescriptorSet(renderData->materialSetLayout); + m_gfxDevice->updateDescriptorCombinedImageSampler(m_descriptorSet, 0, m_image, renderData->samplers.at(samplerInfo)); LOG_INFO("Loaded texture: {}, width: {} height: {}", path, width, height); diff --git a/src/util/model_loader.cpp b/src/util/model_loader.cpp index 5be2a38..602e171 100644 --- a/src/util/model_loader.cpp +++ b/src/util/model_loader.cpp @@ -182,7 +182,7 @@ namespace engine::util { absPath /= texPath.C_Str(); try { textures[i] = std::make_shared( - parent->app()->renderData, absPath.string(), + &parent->app()->renderData, absPath.string(), resources::Texture::Filtering::TRILINEAR); } catch (const std::runtime_error&) { textures[i] = parent->app()->getResource("builtin.white"); diff --git a/test/src/game.cpp b/test/src/game.cpp index f1a14ea..9d28704 100644 --- a/test/src/game.cpp +++ b/test/src/game.cpp @@ -84,12 +84,12 @@ void playGame(GameSettings settings) /* shared resources */ auto grassTexture = std::make_shared( - app.renderData, + &app.renderData, app.getResourcePath("textures/grass.jpg"), engine::resources::Texture::Filtering::ANISOTROPIC ); auto spaceTexture = std::make_shared( - app.renderData, + &app.renderData, app.getResourcePath("textures/space2.png"), engine::resources::Texture::Filtering::ANISOTROPIC );