Renderer: Add mipmaps generation support

This commit is contained in:
SirLynix
2023-05-14 18:55:41 +02:00
parent 3712b641f8
commit 1d32af53c5
33 changed files with 488 additions and 183 deletions

View File

@@ -13,6 +13,8 @@ namespace Nz
OpenGLTexture::OpenGLTexture(OpenGLDevice& device, const TextureInfo& textureInfo) :
m_textureInfo(textureInfo)
{
m_textureInfo.levelCount = std::min(m_textureInfo.levelCount, Image::GetMaxLevel(m_textureInfo.type, m_textureInfo.width, m_textureInfo.height, m_textureInfo.depth));
if (!m_texture.Create(device))
throw std::runtime_error("failed to create texture object");
@@ -71,6 +73,16 @@ namespace Nz
#endif
}
OpenGLTexture::OpenGLTexture(OpenGLDevice& device, const TextureInfo& textureInfo, const void* initialData, bool buildMipmaps, unsigned int srcWidth, unsigned int srcHeight) :
OpenGLTexture(device, textureInfo)
{
NazaraAssert(initialData, "missing initial data");
Update(initialData, srcWidth, srcHeight, 0);
if (buildMipmaps && m_textureInfo.levelCount > 1)
m_texture.GenerateMipmap();
}
OpenGLTexture::OpenGLTexture(std::shared_ptr<OpenGLTexture> parentTexture, const TextureViewInfo& viewInfo) :
m_parentTexture(std::move(parentTexture))
{