Add support for MAX_COMBINED_TEXTURES, which allows more texture support than with the original fixed pipeline texture check under OpenGL. Now, more than 4 textures should also work with newer gfx cards and drivers, which often only support 4 fixed pipeline textures.

Moreover, now you can also set more than the maximal texture layers defined in IrrCompileConfig, simply by calling setTexture in the driver. The MAX_MATERIAL_TEXTURES thus only defines how many textures and configurations are stored in material properties. Currently only used under OpenGL.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4200 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2012-06-24 20:18:30 +00:00
parent 483c085f06
commit 5feef493c1
2 changed files with 19 additions and 3 deletions

View File

@ -2421,7 +2421,7 @@ void COpenGLDriver::drawPixel(u32 x, u32 y, const SColor &color)
bool COpenGLDriver::setActiveTexture(u32 stage, const video::ITexture* texture)
{
if (stage >= MaxTextureUnits)
if (stage >= MaxSupportedTextures)
return false;
if (CurrentTexture[stage]==texture)
@ -2460,7 +2460,7 @@ bool COpenGLDriver::setActiveTexture(u32 stage, const video::ITexture* texture)
bool COpenGLDriver::disableTextures(u32 fromStage)
{
bool result=true;
for (u32 i=fromStage; i<MaxTextureUnits; ++i)
for (u32 i=fromStage; i<MaxSupportedTextures; ++i)
result &= setActiveTexture(i, 0);
return result;
}

View File

@ -567,14 +567,30 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
#endif
#endif // _IRR_WINDOWS_API_
GLint num;
GLint num=0;
// set some properties
#if defined(GL_ARB_multitexture) || defined(GL_VERSION_1_3)
if (Version>102 || FeatureAvailable[IRR_ARB_multitexture])
{
#if defined(GL_MAX_TEXTURE_UNITS)
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &num);
#elif defined(GL_MAX_TEXTURE_UNITS_ARB)
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &num);
#endif
MaxSupportedTextures=static_cast<u8>(num);
}
#endif
#if defined(GL_ARB_vertex_shader) || defined(GL_VERSION_2_0)
if (Version>=200 || FeatureAvailable[IRR_ARB_vertex_shader])
{
num=0;
#if defined(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS)
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &num);
#elif defined(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB)
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, &num);
#endif
MaxSupportedTextures=core::max_(MaxSupportedTextures,static_cast<u8>(num));
}
#endif
glGetIntegerv(GL_MAX_LIGHTS, &num);
MaxLights=static_cast<u8>(num);