Commit 5f619ddf authored by nadro's avatar nadro

- Fixed issue with mipmaps generation in OpenGL.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4507 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 9670a8ba
...@@ -445,30 +445,15 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level) ...@@ -445,30 +445,15 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
if (!level && newTexture) if (!level && newTexture)
{ {
if (!IsCompressed && HasMipMaps && !mipmapData && Driver->queryFeature(EVDF_MIP_MAP_AUTO_UPDATE)) if (IsCompressed && !mipmapData)
{ {
if (!MipmapLegacyMode && AutomaticMipmapUpdate) if (image->hasMipMaps())
{ mipmapData = static_cast<u8*>(image->lock())+compressedDataSize;
glEnable(GL_TEXTURE_2D); else
Driver->extGlGenerateMipmap(GL_TEXTURE_2D); HasMipMaps = false;
}
} }
else if(HasMipMaps)
{
// Either generate manually due to missing capability
// or use predefined mipmap data eg. for compressed textures
AutomaticMipmapUpdate=false;
if (IsCompressed && !mipmapData) regenerateMipMapLevels(mipmapData);
{
if (image->hasMipMaps())
mipmapData = static_cast<u8*>(image->lock())+compressedDataSize;
else
HasMipMaps = false;
}
regenerateMipMapLevels(mipmapData);
}
if (HasMipMaps) // might have changed in regenerateMipMapLevels if (HasMipMaps) // might have changed in regenerateMipMapLevels
{ {
...@@ -686,12 +671,34 @@ bool COpenGLTexture::hasMipMaps() const ...@@ -686,12 +671,34 @@ bool COpenGLTexture::hasMipMaps() const
//! modifying the texture //! modifying the texture
void COpenGLTexture::regenerateMipMapLevels(void* mipmapData) void COpenGLTexture::regenerateMipMapLevels(void* mipmapData)
{ {
if (AutomaticMipmapUpdate || !HasMipMaps || !Image) // texture require mipmaps?
if (!HasMipMaps)
return; return;
if (IsCompressed && !mipmapData)
return; // we don't use custom data for mipmaps.
if ((Image->getDimension().Width==1) && (Image->getDimension().Height==1)) if (!mipmapData)
{
// compressed textures require custom data for prepare mipmaps.
if (IsCompressed)
return;
// texture use legacy method for generate mipmaps?
if (AutomaticMipmapUpdate && MipmapLegacyMode)
return;
// hardware doesn't support generate mipmaps for certain texture but image data doesn't exist or is wrong.
if (!AutomaticMipmapUpdate && (!Image || (Image && ((Image->getDimension().Width==1) && (Image->getDimension().Height==1)))))
return;
}
// hardware moethods for generate mipmaps.
if (!mipmapData && AutomaticMipmapUpdate && !MipmapLegacyMode)
{
glEnable(GL_TEXTURE_2D);
Driver->extGlGenerateMipmap(GL_TEXTURE_2D);
return; return;
}
// Manually create mipmaps or use prepared version // Manually create mipmaps or use prepared version
u32 compressedDataSize = 0; u32 compressedDataSize = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment