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,20 +445,6 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level) ...@@ -445,20 +445,6 @@ 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 (!MipmapLegacyMode && AutomaticMipmapUpdate)
{
glEnable(GL_TEXTURE_2D);
Driver->extGlGenerateMipmap(GL_TEXTURE_2D);
}
}
else if(HasMipMaps)
{
// Either generate manually due to missing capability
// or use predefined mipmap data eg. for compressed textures
AutomaticMipmapUpdate=false;
if (IsCompressed && !mipmapData) if (IsCompressed && !mipmapData)
{ {
if (image->hasMipMaps()) if (image->hasMipMaps())
...@@ -468,7 +454,6 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level) ...@@ -468,7 +454,6 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
} }
regenerateMipMapLevels(mipmapData); regenerateMipMapLevels(mipmapData);
}
if (HasMipMaps) // might have changed in regenerateMipMapLevels if (HasMipMaps) // might have changed in regenerateMipMapLevels
{ {
...@@ -686,13 +671,35 @@ bool COpenGLTexture::hasMipMaps() const ...@@ -686,13 +671,35 @@ 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)
// we don't use custom data for mipmaps.
if (!mipmapData)
{
// compressed textures require custom data for prepare mipmaps.
if (IsCompressed)
return; return;
if ((Image->getDimension().Width==1) && (Image->getDimension().Height==1))
// texture use legacy method for generate mipmaps?
if (AutomaticMipmapUpdate && MipmapLegacyMode)
return; 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;
}
// Manually create mipmaps or use prepared version // Manually create mipmaps or use prepared version
u32 compressedDataSize = 0; u32 compressedDataSize = 0;
u32 width=Image->getDimension().Width; u32 width=Image->getDimension().Width;
......
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