Texture are no longer associated with a RenderTexture
Former-commit-id: 4430c36afd081f20b89322ca1e0c2b8c4ef73ce5
This commit is contained in:
parent
d4abb8fc49
commit
6732761108
|
|
@ -16,7 +16,6 @@
|
||||||
#include <Nazara/Utility/Image.hpp>
|
#include <Nazara/Utility/Image.hpp>
|
||||||
#include <Nazara/Utility/PixelFormat.hpp>
|
#include <Nazara/Utility/PixelFormat.hpp>
|
||||||
|
|
||||||
class NzRenderTexture;
|
|
||||||
class NzTexture;
|
class NzTexture;
|
||||||
|
|
||||||
using NzTextureConstRef = NzResourceRef<const NzTexture>;
|
using NzTextureConstRef = NzResourceRef<const NzTexture>;
|
||||||
|
|
@ -26,8 +25,6 @@ struct NzTextureImpl;
|
||||||
|
|
||||||
class NAZARA_API NzTexture : public NzResource, NzNonCopyable
|
class NAZARA_API NzTexture : public NzResource, NzNonCopyable
|
||||||
{
|
{
|
||||||
friend NzRenderTexture;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NzTexture() = default;
|
NzTexture() = default;
|
||||||
explicit NzTexture(const NzImage& image);
|
explicit NzTexture(const NzImage& image);
|
||||||
|
|
@ -52,7 +49,6 @@ class NAZARA_API NzTexture : public NzResource, NzNonCopyable
|
||||||
|
|
||||||
bool IsCompressed() const;
|
bool IsCompressed() const;
|
||||||
bool IsCubemap() const;
|
bool IsCubemap() const;
|
||||||
bool IsTarget() const;
|
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
|
|
||||||
// Load
|
// Load
|
||||||
|
|
@ -95,9 +91,6 @@ class NAZARA_API NzTexture : public NzResource, NzNonCopyable
|
||||||
static bool IsTypeSupported(nzImageType type);
|
static bool IsTypeSupported(nzImageType type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NzRenderTexture* GetRenderTexture() const;
|
|
||||||
void SetRenderTexture(NzRenderTexture* renderTexture);
|
|
||||||
|
|
||||||
NzTextureImpl* m_impl = nullptr;
|
NzTextureImpl* m_impl = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -192,12 +192,6 @@ bool NzRenderTexture::AttachTexture(nzAttachmentPoint attachmentPoint, nzUInt8 i
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (texture->GetRenderTexture() != nullptr)
|
|
||||||
{
|
|
||||||
NazaraError("Texture already used by another render texture");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (formatTypeToAttachment[NzPixelFormat::GetType(texture->GetFormat())] != attachmentPoint)
|
if (formatTypeToAttachment[NzPixelFormat::GetType(texture->GetFormat())] != attachmentPoint)
|
||||||
{
|
{
|
||||||
NazaraError("Pixel format type does not match attachment point type");
|
NazaraError("Pixel format type does not match attachment point type");
|
||||||
|
|
@ -250,7 +244,6 @@ bool NzRenderTexture::AttachTexture(nzAttachmentPoint attachmentPoint, nzUInt8 i
|
||||||
attachment.texture = texture;
|
attachment.texture = texture;
|
||||||
|
|
||||||
texture->AddResourceListener(this);
|
texture->AddResourceListener(this);
|
||||||
texture->SetRenderTexture(this);
|
|
||||||
|
|
||||||
m_impl->checked = false;
|
m_impl->checked = false;
|
||||||
m_impl->drawBuffersUpdated = false;
|
m_impl->drawBuffersUpdated = false;
|
||||||
|
|
@ -345,10 +338,7 @@ void NzRenderTexture::Destroy()
|
||||||
if (attachment.isBuffer)
|
if (attachment.isBuffer)
|
||||||
glDeleteRenderbuffers(1, &attachment.buffer); // Les Renderbuffers sont partagés entre les contextes: Ne posera pas de problème
|
glDeleteRenderbuffers(1, &attachment.buffer); // Les Renderbuffers sont partagés entre les contextes: Ne posera pas de problème
|
||||||
else
|
else
|
||||||
{
|
|
||||||
attachment.texture->SetRenderTexture(nullptr);
|
|
||||||
attachment.texture->RemoveResourceListener(this);
|
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);
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, NzOpenGL::Attachment[attachmentPoint]+index, 0, 0, 0);
|
||||||
|
|
||||||
attachement.texture->RemoveResourceListener(this);
|
attachement.texture->RemoveResourceListener(this);
|
||||||
attachement.texture->SetRenderTexture(nullptr);
|
attachement.texture = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ struct NzTextureImpl
|
||||||
nzImageType type;
|
nzImageType type;
|
||||||
nzPixelFormat format;
|
nzPixelFormat format;
|
||||||
nzUInt8 levelCount;
|
nzUInt8 levelCount;
|
||||||
NzRenderTexture* renderTexture = nullptr;
|
|
||||||
bool mipmapping = false;
|
bool mipmapping = false;
|
||||||
bool mipmapsUpdated = true;
|
bool mipmapsUpdated = true;
|
||||||
unsigned int depth;
|
unsigned int depth;
|
||||||
|
|
@ -529,19 +528,6 @@ bool NzTexture::IsCubemap() const
|
||||||
return m_impl->type == nzImageType_Cubemap;
|
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
|
bool NzTexture::IsValid() const
|
||||||
{
|
{
|
||||||
return m_impl != nullptr;
|
return m_impl != nullptr;
|
||||||
|
|
@ -1032,12 +1018,6 @@ bool NzTexture::Update(const nzUInt8* pixels, const NzBoxui& box, unsigned int s
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_impl->renderTexture)
|
|
||||||
{
|
|
||||||
NazaraError("Texture is a target, it cannot be updated");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_impl->type == nzImageType_Cubemap)
|
if (m_impl->type == nzImageType_Cubemap)
|
||||||
{
|
{
|
||||||
NazaraError("Update is not designed for cubemaps, use UpdateFace instead");
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_impl->renderTexture)
|
|
||||||
{
|
|
||||||
NazaraError("Texture is a target, it cannot be updated");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_impl->type != nzImageType_Cubemap)
|
if (m_impl->type != nzImageType_Cubemap)
|
||||||
{
|
{
|
||||||
NazaraError("UpdateFace is designed for cubemaps, use Update instead");
|
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) + ')');
|
NazaraError("Image type not handled (0x" + NzString::Number(type, 16) + ')');
|
||||||
return false;
|
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;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue