Commit 5d3bb13d authored by nadro's avatar nadro

- fixed mipmapping issues visible in example no. 11.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4131 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 338ba2ac
......@@ -23,7 +23,7 @@ namespace video
COpenGLTexture::COpenGLTexture(IImage* origImage, const io::path& name, void* mipmapData, COpenGLDriver* driver)
: ITexture(name), ColorFormat(ECF_A8R8G8B8), Driver(driver), Image(0), MipImage(0),
TextureName(0), InternalFormat(GL_RGBA), PixelFormat(GL_BGRA_EXT),
PixelType(GL_UNSIGNED_BYTE), MipLevelStored(0),
PixelType(GL_UNSIGNED_BYTE), MipLevelStored(0), MipmapLegacyMode(true),
IsRenderTarget(false), AutomaticMipmapUpdate(false),
ReadOnlyLock(false), KeepImage(true)
{
......@@ -60,8 +60,8 @@ COpenGLTexture::COpenGLTexture(IImage* origImage, const io::path& name, void* mi
COpenGLTexture::COpenGLTexture(const io::path& name, COpenGLDriver* driver)
: ITexture(name), ColorFormat(ECF_A8R8G8B8), Driver(driver), Image(0), MipImage(0),
TextureName(0), InternalFormat(GL_RGBA), PixelFormat(GL_BGRA_EXT),
PixelType(GL_UNSIGNED_BYTE), MipLevelStored(0),
HasMipMaps(true), IsRenderTarget(false), AutomaticMipmapUpdate(false),
PixelType(GL_UNSIGNED_BYTE), MipLevelStored(0), HasMipMaps(true),
MipmapLegacyMode(true), IsRenderTarget(false), AutomaticMipmapUpdate(false),
ReadOnlyLock(false), KeepImage(true)
{
#ifdef _DEBUG
......@@ -314,8 +314,6 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
if (Driver->testGLError())
os::Printer::log("Could not bind Texture", ELL_ERROR);
bool mipmapLegacyMode = true;
// mipmap handling for main texture
if (!level && newTexture)
{
......@@ -324,20 +322,22 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
// auto generate if possible and no mipmap data is given
if (HasMipMaps && !mipmapData && Driver->queryFeature(EVDF_MIP_MAP_AUTO_UPDATE))
{
if(!Driver->queryFeature(EVDF_FRAMEBUFFER_OBJECT))
if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED))
glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_FASTEST);
else if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_QUALITY))
glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
else
glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_DONT_CARE);
AutomaticMipmapUpdate=true;
if (!Driver->queryFeature(EVDF_FRAMEBUFFER_OBJECT))
{
if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED))
glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_FASTEST);
else if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_QUALITY))
glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
else
glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_DONT_CARE);
// automatically generate and update mipmaps
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE );
AutomaticMipmapUpdate=true;
MipmapLegacyMode=true;
}
else
mipmapLegacyMode = false;
MipmapLegacyMode=false;
}
else
#endif
......@@ -375,15 +375,10 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
image->getDimension().Height, PixelFormat, PixelType, source);
image->unlock();
if (!mipmapLegacyMode)
if (!MipmapLegacyMode && AutomaticMipmapUpdate)
{
glEnable(GL_TEXTURE_2D);
Driver->extGlGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
AutomaticMipmapUpdate=true;
}
if (Driver->testGLError())
......
......@@ -138,6 +138,7 @@ protected:
u8 MipLevelStored;
bool HasMipMaps;
bool MipmapLegacyMode;
bool IsRenderTarget;
bool AutomaticMipmapUpdate;
bool ReadOnlyLock;
......
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