Commit 56ebb84c authored by nadro's avatar nadro

- Fixed issue with mipmaps in OpenGL.

- Fixed issue with cube maps filtering in OpenGL.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5260 dfc29bdd-3216-0410-991c-e03cc46cb475
parent d72c407e
...@@ -163,8 +163,6 @@ core::array<IImage*> CImageLoaderPVR::loadImages(io::IReadFile* file, E_TEXTURE_ ...@@ -163,8 +163,6 @@ core::array<IImage*> CImageLoaderPVR::loadImages(io::IReadFile* file, E_TEXTURE_
{ {
imageArray.set_used(6); imageArray.set_used(6);
tmpType = ETT_CUBEMAP; tmpType = ETT_CUBEMAP;
imageArray.reallocate(6);
} }
else if (header.Depth > 1) // 3d texture else if (header.Depth > 1) // 3d texture
{ {
...@@ -192,8 +190,10 @@ core::array<IImage*> CImageLoaderPVR::loadImages(io::IReadFile* file, E_TEXTURE_ ...@@ -192,8 +190,10 @@ core::array<IImage*> CImageLoaderPVR::loadImages(io::IReadFile* file, E_TEXTURE_
if (header.MipMapCount > 1) if (header.MipMapCount > 1)
{ {
for (u32 j = 0; j < imageArray.size(); ++j) mipMapsDataArray.set_used(imageArray.size());
mipMapsDataArray.push_back(new u8[dataSize]);
for (u32 j = 0; j < mipMapsDataArray.size(); ++j)
mipMapsDataArray[j] =new u8[dataSize];
} }
// read texture // read texture
......
...@@ -316,8 +316,8 @@ public: ...@@ -316,8 +316,8 @@ public:
if (data) if (data)
{ {
u32 width = Size.Width >> layer; u32 width = Size.Width;
u32 height = Size.Height >> layer; u32 height = Size.Height;
u8* tmpData = static_cast<u8*>(data); u8* tmpData = static_cast<u8*>(data);
u32 dataSize = 0; u32 dataSize = 0;
u32 level = 0; u32 level = 0;
......
...@@ -2699,6 +2699,8 @@ void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool reset ...@@ -2699,6 +2699,8 @@ void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool reset
} }
} }
const GLenum tmpType = tmpTexture->getOpenGLTextureType();
COpenGLTexture::SStatesCache& statesCache = tmpTexture->getStatesCache(); COpenGLTexture::SStatesCache& statesCache = tmpTexture->getStatesCache();
if (resetAllRenderstates) if (resetAllRenderstates)
...@@ -2712,10 +2714,10 @@ void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool reset ...@@ -2712,10 +2714,10 @@ void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool reset
if (material.TextureLayer[i].LODBias) if (material.TextureLayer[i].LODBias)
{ {
const float tmp = core::clamp(material.TextureLayer[i].LODBias * 0.125f, -MaxTextureLODBias, MaxTextureLODBias); const float tmp = core::clamp(material.TextureLayer[i].LODBias * 0.125f, -MaxTextureLODBias, MaxTextureLODBias);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, tmp); glTexParameterf(tmpType, GL_TEXTURE_LOD_BIAS, tmp);
} }
else else
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, 0.f); glTexParameterf(tmpType, GL_TEXTURE_LOD_BIAS, 0.f);
statesCache.LODBias = material.TextureLayer[i].LODBias; statesCache.LODBias = material.TextureLayer[i].LODBias;
} }
...@@ -2746,7 +2748,7 @@ void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool reset ...@@ -2746,7 +2748,7 @@ void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool reset
if (!statesCache.IsCached || material.TextureLayer[i].BilinearFilter != statesCache.BilinearFilter || if (!statesCache.IsCached || material.TextureLayer[i].BilinearFilter != statesCache.BilinearFilter ||
material.TextureLayer[i].TrilinearFilter != statesCache.TrilinearFilter) material.TextureLayer[i].TrilinearFilter != statesCache.TrilinearFilter)
{ {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, glTexParameteri(tmpType, GL_TEXTURE_MAG_FILTER,
(material.TextureLayer[i].BilinearFilter || material.TextureLayer[i].TrilinearFilter) ? GL_LINEAR : GL_NEAREST); (material.TextureLayer[i].BilinearFilter || material.TextureLayer[i].TrilinearFilter) ? GL_LINEAR : GL_NEAREST);
statesCache.BilinearFilter = material.TextureLayer[i].BilinearFilter; statesCache.BilinearFilter = material.TextureLayer[i].BilinearFilter;
...@@ -2758,7 +2760,7 @@ void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool reset ...@@ -2758,7 +2760,7 @@ void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool reset
if (!statesCache.IsCached || material.TextureLayer[i].BilinearFilter != statesCache.BilinearFilter || if (!statesCache.IsCached || material.TextureLayer[i].BilinearFilter != statesCache.BilinearFilter ||
material.TextureLayer[i].TrilinearFilter != statesCache.TrilinearFilter || !statesCache.MipMapStatus) material.TextureLayer[i].TrilinearFilter != statesCache.TrilinearFilter || !statesCache.MipMapStatus)
{ {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, glTexParameteri(tmpType, GL_TEXTURE_MIN_FILTER,
material.TextureLayer[i].TrilinearFilter ? GL_LINEAR_MIPMAP_LINEAR : material.TextureLayer[i].TrilinearFilter ? GL_LINEAR_MIPMAP_LINEAR :
material.TextureLayer[i].BilinearFilter ? GL_LINEAR_MIPMAP_NEAREST : material.TextureLayer[i].BilinearFilter ? GL_LINEAR_MIPMAP_NEAREST :
GL_NEAREST_MIPMAP_NEAREST); GL_NEAREST_MIPMAP_NEAREST);
...@@ -2773,7 +2775,7 @@ void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool reset ...@@ -2773,7 +2775,7 @@ void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool reset
if (!statesCache.IsCached || material.TextureLayer[i].BilinearFilter != statesCache.BilinearFilter || if (!statesCache.IsCached || material.TextureLayer[i].BilinearFilter != statesCache.BilinearFilter ||
material.TextureLayer[i].TrilinearFilter != statesCache.TrilinearFilter || statesCache.MipMapStatus) material.TextureLayer[i].TrilinearFilter != statesCache.TrilinearFilter || statesCache.MipMapStatus)
{ {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, glTexParameteri(tmpType, GL_TEXTURE_MIN_FILTER,
(material.TextureLayer[i].BilinearFilter || material.TextureLayer[i].TrilinearFilter) ? GL_LINEAR : GL_NEAREST); (material.TextureLayer[i].BilinearFilter || material.TextureLayer[i].TrilinearFilter) ? GL_LINEAR : GL_NEAREST);
statesCache.BilinearFilter = material.TextureLayer[i].BilinearFilter; statesCache.BilinearFilter = material.TextureLayer[i].BilinearFilter;
...@@ -2786,7 +2788,7 @@ void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool reset ...@@ -2786,7 +2788,7 @@ void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool reset
if (FeatureAvailable[IRR_EXT_texture_filter_anisotropic] && if (FeatureAvailable[IRR_EXT_texture_filter_anisotropic] &&
(!statesCache.IsCached || material.TextureLayer[i].AnisotropicFilter != statesCache.AnisotropicFilter)) (!statesCache.IsCached || material.TextureLayer[i].AnisotropicFilter != statesCache.AnisotropicFilter))
{ {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, glTexParameteri(tmpType, GL_TEXTURE_MAX_ANISOTROPY_EXT,
material.TextureLayer[i].AnisotropicFilter>1 ? core::min_(MaxAnisotropy, material.TextureLayer[i].AnisotropicFilter) : 1); material.TextureLayer[i].AnisotropicFilter>1 ? core::min_(MaxAnisotropy, material.TextureLayer[i].AnisotropicFilter) : 1);
statesCache.AnisotropicFilter = material.TextureLayer[i].AnisotropicFilter; statesCache.AnisotropicFilter = material.TextureLayer[i].AnisotropicFilter;
...@@ -2795,19 +2797,19 @@ void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool reset ...@@ -2795,19 +2797,19 @@ void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool reset
if (!statesCache.IsCached || material.TextureLayer[i].TextureWrapU != statesCache.WrapU) if (!statesCache.IsCached || material.TextureLayer[i].TextureWrapU != statesCache.WrapU)
{ {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, getTextureWrapMode(material.TextureLayer[i].TextureWrapU)); glTexParameteri(tmpType, GL_TEXTURE_WRAP_S, getTextureWrapMode(material.TextureLayer[i].TextureWrapU));
statesCache.WrapU = material.TextureLayer[i].TextureWrapU; statesCache.WrapU = material.TextureLayer[i].TextureWrapU;
} }
if (!statesCache.IsCached || material.TextureLayer[i].TextureWrapV != statesCache.WrapV) if (!statesCache.IsCached || material.TextureLayer[i].TextureWrapV != statesCache.WrapV)
{ {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, getTextureWrapMode(material.TextureLayer[i].TextureWrapV)); glTexParameteri(tmpType, GL_TEXTURE_WRAP_T, getTextureWrapMode(material.TextureLayer[i].TextureWrapV));
statesCache.WrapV = material.TextureLayer[i].TextureWrapV; statesCache.WrapV = material.TextureLayer[i].TextureWrapV;
} }
if (!statesCache.IsCached || material.TextureLayer[i].TextureWrapW != statesCache.WrapW) if (!statesCache.IsCached || material.TextureLayer[i].TextureWrapW != statesCache.WrapW)
{ {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, getTextureWrapMode(material.TextureLayer[i].TextureWrapW)); glTexParameteri(tmpType, GL_TEXTURE_WRAP_R, getTextureWrapMode(material.TextureLayer[i].TextureWrapW));
statesCache.WrapW = material.TextureLayer[i].TextureWrapW; statesCache.WrapW = material.TextureLayer[i].TextureWrapW;
} }
......
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