From bc8bc289f8819d5d1f3f68f0d5a5272875720faa Mon Sep 17 00:00:00 2001 From: Ada Date: Thu, 3 Apr 2025 21:56:16 +1000 Subject: [PATCH] Slight improvement on self-rendering, still a bit broken --- .../entities-renderer/src/RenderableCanvasEntityItem.cpp | 8 +++++--- libraries/entities/src/CanvasEntityItem.cpp.in | 4 ---- libraries/entities/src/CanvasEntityItem.h.in | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableCanvasEntityItem.cpp b/libraries/entities-renderer/src/RenderableCanvasEntityItem.cpp index 313fd70eb7..72bd590bf1 100644 --- a/libraries/entities-renderer/src/RenderableCanvasEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableCanvasEntityItem.cpp @@ -20,6 +20,7 @@ using namespace render::entities; CanvasEntityRenderer::CanvasEntityRenderer(const EntityItemPointer& entity) : Parent(entity) { _geometryId = DependencyManager::get()->allocateID(); _material->setCullFaceMode(graphics::MaterialKey::CullFaceMode::CULL_NONE); + _material->setUnlit(true); addMaterial(graphics::MaterialLayer(_material, 0), "0"); updateMaterials(true); } @@ -60,6 +61,9 @@ void CanvasEntityRenderer::doRender(RenderArgs* args) { } Transform transform; + withReadLock([&] { + transform = _renderTransform; + }); gpu::Batch* batch = args->_batch; @@ -85,7 +89,7 @@ void CanvasEntityRenderer::doRender(RenderArgs* args) { } DependencyManager::get()->renderQuad( - *batch, glm::vec2(-0.5f), glm::vec2(0.5f), glm::vec2(0.0f), glm::vec2(1.0f), + *batch, glm::vec2(-0.5f), glm::vec2(0.5f), glm::vec2(0.0f, 1.0f), glm::vec2(1.0f, 0.0f), glm::vec4(1.0f), _geometryId ); @@ -93,6 +97,4 @@ void CanvasEntityRenderer::doRender(RenderArgs* args) { // we have to reset this to white for other simple shapes batch->setResourceTexture(graphics::slot::texture::Texture::MaterialAlbedo, DependencyManager::get()->getWhiteTexture()); } - - qCritical("Canvas rendered"); } diff --git a/libraries/entities/src/CanvasEntityItem.cpp.in b/libraries/entities/src/CanvasEntityItem.cpp.in index 8d1a831c03..0ed9f7e2d0 100644 --- a/libraries/entities/src/CanvasEntityItem.cpp.in +++ b/libraries/entities/src/CanvasEntityItem.cpp.in @@ -24,7 +24,6 @@ EntityItemPointer CanvasEntityItem::factory(const EntityItemID& entityID, const CanvasEntityItem::CanvasEntityItem(const EntityItemID& entityItemID) : EntityItem(entityItemID) { _type = EntityTypes::Canvas; - _texture = gpu::Texture::createStrict(gpu::Element::COLOR_SRGBA_32, _width, _height, 1, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR)); } CanvasEntityItem::~CanvasEntityItem() {} @@ -251,9 +250,6 @@ void CanvasEntityItem::commit() { } auto texture = gpu::Texture::createStrict(gpu::Element::COLOR_SRGBA_32, getWidth(), getHeight(), 1, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR)); - //texture->setSize(getWidth(), getHeight()); - texture->setStoredMipFormat(gpu::Element::COLOR_SRGBA_32); - texture->setAutoGenerateMips(false); texture->assignStoredMip(0, _imageData.length(), reinterpret_cast(_imageData.constData())); texture->setSource("CanvasEntityRenderer"); _texture = texture; diff --git a/libraries/entities/src/CanvasEntityItem.h.in b/libraries/entities/src/CanvasEntityItem.h.in index e4434b7c65..54a4edf0af 100644 --- a/libraries/entities/src/CanvasEntityItem.h.in +++ b/libraries/entities/src/CanvasEntityItem.h.in @@ -44,7 +44,7 @@ protected: QByteArray _imageData; QVector _commandQueue; - gpu::TexturePointer _texture; + gpu::TexturePointer _texture { nullptr }; }; #endif // hifi_CanvasEntityItem_h