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,
};
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;

View File

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

View File

@ -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);

View File

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

View File

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