Improved Texture mipmap support

Former-commit-id: 0fc3e003a6524e5c026712a3dc695cf80817ea88
This commit is contained in:
Lynix
2013-09-29 10:50:27 +02:00
parent 8ce5f879a8
commit b01fad269e
2 changed files with 30 additions and 14 deletions

View File

@@ -398,6 +398,16 @@ bool NzTexture::EnableMipmapping(bool enable)
return true;
}
void NzTexture::EnsureMipmapsUpdate() const
{
if (m_impl->mipmapping && !m_impl->mipmapsUpdated)
{
NzOpenGL::BindTexture(m_impl->type, m_impl->id);
glGenerateMipmap(NzOpenGL::TextureTarget[m_impl->type]);
m_impl->mipmapsUpdated = true;
}
}
nzUInt8 NzTexture::GetBytesPerPixel() const
{
#if NAZARA_RENDERER_SAFE
@@ -1224,19 +1234,6 @@ bool NzTexture::UpdateFace(nzCubemapFace face, const nzUInt8* pixels, const NzRe
return true;
}
bool NzTexture::Bind() const
{
NzOpenGL::BindTexture(m_impl->type, m_impl->id);
if (m_impl->mipmapping && !m_impl->mipmapsUpdated)
{
glGenerateMipmap(NzOpenGL::TextureTarget[m_impl->type]);
m_impl->mipmapsUpdated = true;
}
return true;
}
unsigned int NzTexture::GetOpenGLID() const
{
#if NAZARA_RENDERER_SAFE
@@ -1372,3 +1369,16 @@ bool NzTexture::IsTypeSupported(nzImageType type)
NazaraError("Image type not handled (0x" + NzString::Number(type, 16) + ')');
return false;
}
void NzTexture::InvalidateMipmaps()
{
#if NAZARA_RENDERER_SAFE
if (!m_impl)
{
NazaraInternalError("Texture must be valid");
return;
}
#endif
m_impl->mipmapsUpdated = false;
}