From 6732761108d1d2b552b1a93d33fd1f36043af800 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 6 Sep 2013 18:23:24 +0200 Subject: [PATCH] Texture are no longer associated with a RenderTexture Former-commit-id: 4430c36afd081f20b89322ca1e0c2b8c4ef73ce5 --- include/Nazara/Renderer/Texture.hpp | 7 ---- src/Nazara/Renderer/RenderTexture.cpp | 12 +------ src/Nazara/Renderer/Texture.cpp | 52 --------------------------- 3 files changed, 1 insertion(+), 70 deletions(-) diff --git a/include/Nazara/Renderer/Texture.hpp b/include/Nazara/Renderer/Texture.hpp index d859e424e..b220a3610 100644 --- a/include/Nazara/Renderer/Texture.hpp +++ b/include/Nazara/Renderer/Texture.hpp @@ -16,7 +16,6 @@ #include #include -class NzRenderTexture; class NzTexture; using NzTextureConstRef = NzResourceRef; @@ -26,8 +25,6 @@ struct NzTextureImpl; class NAZARA_API NzTexture : public NzResource, NzNonCopyable { - friend NzRenderTexture; - public: NzTexture() = default; explicit NzTexture(const NzImage& image); @@ -52,7 +49,6 @@ class NAZARA_API NzTexture : public NzResource, NzNonCopyable bool IsCompressed() const; bool IsCubemap() const; - bool IsTarget() const; bool IsValid() const; // Load @@ -95,9 +91,6 @@ class NAZARA_API NzTexture : public NzResource, NzNonCopyable static bool IsTypeSupported(nzImageType type); private: - NzRenderTexture* GetRenderTexture() const; - void SetRenderTexture(NzRenderTexture* renderTexture); - NzTextureImpl* m_impl = nullptr; }; diff --git a/src/Nazara/Renderer/RenderTexture.cpp b/src/Nazara/Renderer/RenderTexture.cpp index 6da7e64ad..21d56b947 100644 --- a/src/Nazara/Renderer/RenderTexture.cpp +++ b/src/Nazara/Renderer/RenderTexture.cpp @@ -192,12 +192,6 @@ bool NzRenderTexture::AttachTexture(nzAttachmentPoint attachmentPoint, nzUInt8 i return false; } - if (texture->GetRenderTexture() != nullptr) - { - NazaraError("Texture already used by another render texture"); - return false; - } - if (formatTypeToAttachment[NzPixelFormat::GetType(texture->GetFormat())] != attachmentPoint) { NazaraError("Pixel format type does not match attachment point type"); @@ -250,7 +244,6 @@ bool NzRenderTexture::AttachTexture(nzAttachmentPoint attachmentPoint, nzUInt8 i attachment.texture = texture; texture->AddResourceListener(this); - texture->SetRenderTexture(this); m_impl->checked = false; m_impl->drawBuffersUpdated = false; @@ -345,10 +338,7 @@ void NzRenderTexture::Destroy() if (attachment.isBuffer) glDeleteRenderbuffers(1, &attachment.buffer); // Les Renderbuffers sont partagés entre les contextes: Ne posera pas de problème else - { - attachment.texture->SetRenderTexture(nullptr); attachment.texture->RemoveResourceListener(this); - } } } @@ -405,7 +395,7 @@ void NzRenderTexture::Detach(nzAttachmentPoint attachmentPoint, nzUInt8 index) glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, NzOpenGL::Attachment[attachmentPoint]+index, 0, 0, 0); attachement.texture->RemoveResourceListener(this); - attachement.texture->SetRenderTexture(nullptr); + attachement.texture = nullptr; } Unlock(); diff --git a/src/Nazara/Renderer/Texture.cpp b/src/Nazara/Renderer/Texture.cpp index adca65bf3..a715f7580 100644 --- a/src/Nazara/Renderer/Texture.cpp +++ b/src/Nazara/Renderer/Texture.cpp @@ -17,7 +17,6 @@ struct NzTextureImpl nzImageType type; nzPixelFormat format; nzUInt8 levelCount; - NzRenderTexture* renderTexture = nullptr; bool mipmapping = false; bool mipmapsUpdated = true; unsigned int depth; @@ -529,19 +528,6 @@ bool NzTexture::IsCubemap() const return m_impl->type == nzImageType_Cubemap; } -bool NzTexture::IsTarget() const -{ - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return false; - } - #endif - - return m_impl->renderTexture != nullptr; -} - bool NzTexture::IsValid() const { return m_impl != nullptr; @@ -1032,12 +1018,6 @@ bool NzTexture::Update(const nzUInt8* pixels, const NzBoxui& box, unsigned int s return false; } - if (m_impl->renderTexture) - { - NazaraError("Texture is a target, it cannot be updated"); - return false; - } - if (m_impl->type == nzImageType_Cubemap) { NazaraError("Update is not designed for cubemaps, use UpdateFace instead"); @@ -1184,12 +1164,6 @@ bool NzTexture::UpdateFace(nzCubemapFace face, const nzUInt8* pixels, const NzRe return false; } - if (m_impl->renderTexture) - { - NazaraError("Texture is a target, it cannot be updated"); - return false; - } - if (m_impl->type != nzImageType_Cubemap) { NazaraError("UpdateFace is designed for cubemaps, use Update instead"); @@ -1398,29 +1372,3 @@ bool NzTexture::IsTypeSupported(nzImageType type) NazaraError("Image type not handled (0x" + NzString::Number(type, 16) + ')'); return false; } - -NzRenderTexture* NzTexture::GetRenderTexture() const -{ - #ifdef NAZARA_DEBUG - if (!m_impl) - { - NazaraInternalError("Texture must be valid"); - return nullptr; - } - #endif - - return m_impl->renderTexture; -} - -void NzTexture::SetRenderTexture(NzRenderTexture* renderTexture) -{ - #ifdef NAZARA_DEBUG - if (!m_impl) - { - NazaraInternalError("Texture must be valid"); - return; - } - #endif - - m_impl->renderTexture = renderTexture; -}