Commit 0622b4fb authored by hybrid's avatar hybrid

Constrain texture size by maximal allowed value.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2098 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 26ead87b
......@@ -19,8 +19,8 @@ namespace video
COpenGLExtensionHandler::COpenGLExtensionHandler() :
StencilBuffer(false), MultiTextureExtension(false),
TextureCompressionExtension(false),
MaxTextureUnits(1), MaxLights(1), MaxIndices(65535),
MaxAnisotropy(1), MaxUserClipPlanes(0), MaxAuxBuffers(0),
MaxTextureUnits(1), MaxLights(1), MaxAnisotropy(1), MaxUserClipPlanes(0),
MaxAuxBuffers(0), MaxIndices(65535), MaxTextureSize(1),
Version(0), ShaderLanguageVersion(0)
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
,pGlActiveTextureARB(0), pGlClientActiveTextureARB(0),
......@@ -409,6 +409,8 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
MaxIndices=num;
}
#endif
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &num);
MaxTextureSize=static_cast<u8>(num);
glGetIntegerv(GL_MAX_CLIP_PLANES, &num);
MaxUserClipPlanes=static_cast<u8>(num);
glGetIntegerv(GL_AUX_BUFFERS, &num);
......
......@@ -715,14 +715,16 @@ class COpenGLExtensionHandler
u8 MaxTextureUnits;
//! Maximum hardware lights supported
u8 MaxLights;
//! Optimal number of indices per meshbuffer
u32 MaxIndices;
//! Maximal Anisotropy
u8 MaxAnisotropy;
//! Number of user clipplanes
u8 MaxUserClipPlanes;
//! Number of auxiliary buffers
u8 MaxAuxBuffers;
//! Optimal number of indices per meshbuffer
u32 MaxIndices;
//! Maximal texture dimension
u32 MaxTextureSize;
//! OpenGL version as Integer: 100*Major+Minor, i.e. 2.1 becomes 201
u16 Version;
......
......@@ -135,6 +135,17 @@ void COpenGLTexture::getImageData(IImage* image)
return;
}
const f32 ratio = (f32)ImageSize.Width/(f32)ImageSize.Height;
if ((ImageSize.Width>Driver->MaxTextureSize) && (ratio >= 1.0f))
{
ImageSize.Width = Driver->MaxTextureSize;
ImageSize.Height = (u32)(Driver->MaxTextureSize/ratio);
}
else if (ImageSize.Height>Driver->MaxTextureSize)
{
ImageSize.Height = Driver->MaxTextureSize;
ImageSize.Width = (u32)(Driver->MaxTextureSize*ratio);
}
TextureSize=ImageSize.getOptimalSize(!Driver->queryFeature(EVDF_TEXTURE_NPOT));
ColorFormat = getBestColorFormat(image->getColorFormat());
......
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