change reference to pointer

This commit is contained in:
Bailey Harrison 2023-04-24 11:45:47 +01:00
parent 15d62ecf6b
commit 8cbcce5ce4
5 changed files with 11 additions and 11 deletions

View File

@ -20,7 +20,7 @@ public:
ANISOTROPIC, ANISOTROPIC,
}; };
Texture(RenderData& renderData, const std::string& path, Filtering filtering); Texture(RenderData* renderData, const std::string& path, Filtering filtering);
~Texture(); ~Texture();
Texture(const Texture&) = delete; Texture(const Texture&) = delete;
Texture& operator=(const Texture&) = delete; Texture& operator=(const Texture&) = delete;

View File

@ -143,7 +143,7 @@ namespace engine {
} }
{ {
auto whiteTexture = std::make_unique<resources::Texture>( auto whiteTexture = std::make_unique<resources::Texture>(
renderData, &renderData,
getResourcePath("engine/textures/white.png"), getResourcePath("engine/textures/white.png"),
resources::Texture::Filtering::OFF resources::Texture::Filtering::OFF
); );

View File

@ -8,8 +8,8 @@
namespace engine::resources { namespace engine::resources {
Texture::Texture(RenderData& renderData, const std::string& path, Filtering filtering) Texture::Texture(RenderData* renderData, const std::string& path, Filtering filtering)
: m_gfxDevice(renderData.gfxdev.get()) : m_gfxDevice(renderData->gfxdev.get())
{ {
int width, height; int width, height;
@ -41,13 +41,13 @@ Texture::Texture(RenderData& renderData, const std::string& path, Filtering filt
samplerInfo.anisotropicFiltering = true; samplerInfo.anisotropicFiltering = true;
} }
if (renderData.samplers.contains(samplerInfo) == false) { if (renderData->samplers.contains(samplerInfo) == false) {
renderData.samplers.insert(std::make_pair(samplerInfo, m_gfxDevice->createSampler(samplerInfo))); renderData->samplers.insert(std::make_pair(samplerInfo, m_gfxDevice->createSampler(samplerInfo)));
} }
m_image = m_gfxDevice->createImage(width, height, texbuf->data()); m_image = m_gfxDevice->createImage(width, height, texbuf->data());
m_descriptorSet = m_gfxDevice->allocateDescriptorSet(renderData.materialSetLayout); m_descriptorSet = m_gfxDevice->allocateDescriptorSet(renderData->materialSetLayout);
m_gfxDevice->updateDescriptorCombinedImageSampler(m_descriptorSet, 0, m_image, renderData.samplers.at(samplerInfo)); m_gfxDevice->updateDescriptorCombinedImageSampler(m_descriptorSet, 0, m_image, renderData->samplers.at(samplerInfo));
LOG_INFO("Loaded texture: {}, width: {} height: {}", path, width, height); LOG_INFO("Loaded texture: {}, width: {} height: {}", path, width, height);

View File

@ -182,7 +182,7 @@ namespace engine::util {
absPath /= texPath.C_Str(); absPath /= texPath.C_Str();
try { try {
textures[i] = std::make_shared<resources::Texture>( textures[i] = std::make_shared<resources::Texture>(
parent->app()->renderData, absPath.string(), &parent->app()->renderData, absPath.string(),
resources::Texture::Filtering::TRILINEAR); resources::Texture::Filtering::TRILINEAR);
} catch (const std::runtime_error&) { } catch (const std::runtime_error&) {
textures[i] = parent->app()->getResource<resources::Texture>("builtin.white"); textures[i] = parent->app()->getResource<resources::Texture>("builtin.white");

View File

@ -84,12 +84,12 @@ void playGame(GameSettings settings)
/* shared resources */ /* shared resources */
auto grassTexture = std::make_shared<engine::resources::Texture>( auto grassTexture = std::make_shared<engine::resources::Texture>(
app.renderData, &app.renderData,
app.getResourcePath("textures/grass.jpg"), app.getResourcePath("textures/grass.jpg"),
engine::resources::Texture::Filtering::ANISOTROPIC engine::resources::Texture::Filtering::ANISOTROPIC
); );
auto spaceTexture = std::make_shared<engine::resources::Texture>( auto spaceTexture = std::make_shared<engine::resources::Texture>(
app.renderData, &app.renderData,
app.getResourcePath("textures/space2.png"), app.getResourcePath("textures/space2.png"),
engine::resources::Texture::Filtering::ANISOTROPIC engine::resources::Texture::Filtering::ANISOTROPIC
); );