#include "SkyTextureState.hpp"
//#include "glvu.hpp"
+#include <simgear/screen/extensions.hxx>
+
+
+glActiveTextureProc glActiveTexturePtr = 0;
+bool glActiveTextureIsSupported = false;
+
//------------------------------------------------------------------------------
if (0 == s_iNumTextureUnits)
{
int iNumTextureUnits = 0;
-#ifdef GL_ARB_multitexture
+ if (SGIsOpenGLExtensionSupported("GL_ARB_multitexture")) {
+ glActiveTextureIsSupported = true;
+
+ glActiveTexturePtr = (glActiveTextureProc)
+ SGLookupFunction("glActiveTextureARB");
+
+ }
+
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &iNumTextureUnits);
if (iNumTextureUnits > 0)
s_iNumTextureUnits = iNumTextureUnits;
else
s_iNumTextureUnits = 1;
-#endif
}
_pTextureUnitState = new TexState[s_iNumTextureUnits];
//GLVU::CheckForGLError("SkyTextureState::Activate(8)");
for (unsigned int i = 0; i < s_iNumTextureUnits; ++i)
{
-#ifdef GL_ARB_multitexture
- if (s_iNumTextureUnits > 1)
- glActiveTextureARB(GL_TEXTURE0_ARB + i);
-#endif
+ if (glActiveTextureIsSupported && (s_iNumTextureUnits > 1))
+ glActiveTexturePtr(GL_TEXTURE0_ARB + i);
+
bool bEnabled = IsTextureEnabled(i);
if (pCurrent->IsTextureEnabled(i) != bEnabled)
{
}
//GLVU::CheckForGLError("SkyTextureState::Activate()");
}
-#ifdef GL_ARB_multitexture
- if (s_iNumTextureUnits > 1)
- glActiveTextureARB(GL_TEXTURE0_ARB);
-#endif
+ if (glActiveTextureIsSupported && (s_iNumTextureUnits > 1))
+ glActiveTexturePtr(GL_TEXTURE0_ARB);
}
return SKYRESULT_OK;
}
//GLVU::CheckForGLError("SkyTextureState::Activate(8)");
for (unsigned int i = 0; i < s_iNumTextureUnits; ++i)
{
-#ifdef GL_ARB_multitexture
- if (s_iNumTextureUnits > 1)
- glActiveTextureARB(GL_TEXTURE0_ARB + i);
-#endif
+ if (glActiveTextureIsSupported && (s_iNumTextureUnits > 1))
+ glActiveTexturePtr(GL_TEXTURE0_ARB + i);
+
bool bEnabled = IsTextureEnabled(i);
FAIL_RETURN(pCurrent->EnableTexture(i, bEnabled));
//GLVU::CheckForGLError("SkyTextureState::Activate(7)");
FAIL_RETURN(pCurrent->SetTextureParameter(i, GL_TEXTURE_MAG_FILTER, paramValue));
glTexParameteri(eTarget, GL_TEXTURE_MIN_FILTER, paramValue);
-#ifdef GL_ARB_multitexture
- if (s_iNumTextureUnits > 1)
- glActiveTextureARB(GL_TEXTURE0_ARB);
-#endif
+ if(glActiveTextureIsSupported && (s_iNumTextureUnits > 1))
+ glActiveTexturePtr(GL_TEXTURE0_ARB);
}
return SKYRESULT_OK;
}