Commit 5feef493 authored by hybrid's avatar hybrid

Add support for MAX_COMBINED_TEXTURES, which allows more texture support than...

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
parent 483c085f
...@@ -2421,7 +2421,7 @@ void COpenGLDriver::drawPixel(u32 x, u32 y, const SColor &color) ...@@ -2421,7 +2421,7 @@ void COpenGLDriver::drawPixel(u32 x, u32 y, const SColor &color)
bool COpenGLDriver::setActiveTexture(u32 stage, const video::ITexture* texture) bool COpenGLDriver::setActiveTexture(u32 stage, const video::ITexture* texture)
{ {
if (stage >= MaxTextureUnits) if (stage >= MaxSupportedTextures)
return false; return false;
if (CurrentTexture[stage]==texture) if (CurrentTexture[stage]==texture)
...@@ -2460,7 +2460,7 @@ bool COpenGLDriver::setActiveTexture(u32 stage, const video::ITexture* texture) ...@@ -2460,7 +2460,7 @@ bool COpenGLDriver::setActiveTexture(u32 stage, const video::ITexture* texture)
bool COpenGLDriver::disableTextures(u32 fromStage) bool COpenGLDriver::disableTextures(u32 fromStage)
{ {
bool result=true; bool result=true;
for (u32 i=fromStage; i<MaxTextureUnits; ++i) for (u32 i=fromStage; i<MaxSupportedTextures; ++i)
result &= setActiveTexture(i, 0); result &= setActiveTexture(i, 0);
return result; return result;
} }
......
...@@ -567,14 +567,30 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer) ...@@ -567,14 +567,30 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
#endif #endif
#endif // _IRR_WINDOWS_API_ #endif // _IRR_WINDOWS_API_
GLint num; GLint num=0;
// set some properties // set some properties
#if defined(GL_ARB_multitexture) || defined(GL_VERSION_1_3) #if defined(GL_ARB_multitexture) || defined(GL_VERSION_1_3)
if (Version>102 || FeatureAvailable[IRR_ARB_multitexture]) if (Version>102 || FeatureAvailable[IRR_ARB_multitexture])
{ {
#if defined(GL_MAX_TEXTURE_UNITS)
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &num); 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); 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 #endif
glGetIntegerv(GL_MAX_LIGHTS, &num); glGetIntegerv(GL_MAX_LIGHTS, &num);
MaxLights=static_cast<u8>(num); MaxLights=static_cast<u8>(num);
......
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