don't destroy dummy image texture if clearBackgroundImage has been called without setBackgroundImage having been called first

This commit is contained in:
Nick Fisher
2024-06-19 16:38:14 +08:00
parent 735612af66
commit 846f45bb63
2 changed files with 4 additions and 2 deletions

View File

@@ -211,6 +211,7 @@ namespace thermion_filament
uint32_t _imageWidth = 0; uint32_t _imageWidth = 0;
mat4f _imageScale; mat4f _imageScale;
Texture *_imageTexture = nullptr; Texture *_imageTexture = nullptr;
Texture *_dummyImageTexture = nullptr;
utils::Entity _imageEntity; utils::Entity _imageEntity;
VertexBuffer *_imageVb = nullptr; VertexBuffer *_imageVb = nullptr;
IndexBuffer *_imageIb = nullptr; IndexBuffer *_imageIb = nullptr;

View File

@@ -214,7 +214,7 @@ namespace thermion_filament
Log("Created scene maager"); Log("Created scene maager");
_imageTexture = Texture::Builder() _dummyImageTexture = Texture::Builder()
.width(1) .width(1)
.height(1) .height(1)
.levels(0x01) .levels(0x01)
@@ -229,7 +229,7 @@ namespace thermion_filament
.build(*_engine); .build(*_engine);
_imageMaterial->setDefaultParameter("showImage", 0); _imageMaterial->setDefaultParameter("showImage", 0);
_imageMaterial->setDefaultParameter("backgroundColor", RgbaType::sRGB, float4(1.0f, 1.0f, 1.0f, 0.0f)); _imageMaterial->setDefaultParameter("backgroundColor", RgbaType::sRGB, float4(1.0f, 1.0f, 1.0f, 0.0f));
_imageMaterial->setDefaultParameter("image", _imageTexture, _imageSampler); _imageMaterial->setDefaultParameter("image", _dummyImageTexture, _imageSampler);
} }
catch (...) catch (...)
{ {
@@ -549,6 +549,7 @@ namespace thermion_filament
void FilamentViewer::clearBackgroundImage() void FilamentViewer::clearBackgroundImage()
{ {
_imageMaterial->setDefaultParameter("image", _dummyImageTexture, _imageSampler);
_imageMaterial->setDefaultParameter("showImage", 0); _imageMaterial->setDefaultParameter("showImage", 0);
if (_imageTexture) if (_imageTexture)
{ {