Added support for the texture_env_dot3 extension.
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
#define GL_COMBINE_ARB 0x8570
|
||||
#define GL_COMBINE_RGB_ARB 0x8571
|
||||
#define GL_COMBINE_ALPHA_ARB 0x8572
|
||||
#define GL_DOT3_RGB_ARB 0x86AE
|
||||
#define GL_DOT3_RGBA_ARB 0x86AF
|
||||
#define GL_SOURCE0_RGB_ARB 0x8580
|
||||
#define GL_SOURCE1_RGB_ARB 0x8581
|
||||
#define GL_SOURCE2_RGB_ARB 0x8582
|
||||
@@ -116,7 +118,9 @@ class SG_EXPORT TexEnvCombine : public StateAttribute
|
||||
ADD = GL_ADD,
|
||||
ADD_SIGNED = GL_ADD_SIGNED_ARB,
|
||||
INTERPOLATE = GL_INTERPOLATE_ARB,
|
||||
SUBTRACT = GL_SUBTRACT_ARB
|
||||
SUBTRACT = GL_SUBTRACT_ARB,
|
||||
DOT3_RGB = GL_DOT3_RGB_ARB,
|
||||
DOT3_RGBA = GL_DOT3_RGBA_ARB
|
||||
};
|
||||
|
||||
void setCombine_RGB(GLint cm) { _combine_RGB = cm; }
|
||||
|
||||
@@ -31,18 +31,30 @@ TexEnvCombine::~TexEnvCombine()
|
||||
|
||||
void TexEnvCombine::apply(State&) const
|
||||
{
|
||||
static bool isTexEnvCombineSupported =
|
||||
static bool s_isTexEnvCombineSupported =
|
||||
isGLExtensionSupported("GL_ARB_texture_env_combine");
|
||||
|
||||
static bool isTexEnvCrossbarSupported =
|
||||
static bool s_isTexEnvCrossbarSupported =
|
||||
isGLExtensionSupported("GL_ARB_texture_env_crossbar");
|
||||
|
||||
if (isTexEnvCrossbarSupported || (!_needsTexEnvCrossbar && isTexEnvCombineSupported))
|
||||
static bool s_isTexEnvDot3Supported =
|
||||
isGLExtensionSupported("GL_ARB_texture_env_dot3");
|
||||
|
||||
bool needsTexEnvDot3 = (_combine_RGB==DOT3_RGB) ||
|
||||
(_combine_RGB==DOT3_RGBA);
|
||||
|
||||
bool supported = s_isTexEnvCombineSupported;
|
||||
if (_needsTexEnvCrossbar && !s_isTexEnvCrossbarSupported) supported = false;
|
||||
if (needsTexEnvDot3 && !s_isTexEnvDot3Supported) supported = false;
|
||||
|
||||
if (supported)
|
||||
{
|
||||
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
|
||||
|
||||
glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, _combine_RGB);
|
||||
glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, _combine_Alpha);
|
||||
|
||||
if (_combine_RGB!=DOT3_RGBA)
|
||||
glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, _combine_Alpha);
|
||||
|
||||
glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB,_source0_RGB );
|
||||
glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, _source1_RGB);
|
||||
|
||||
@@ -202,6 +202,8 @@ bool TexEnvCombine_matchCombineParamStr(const char* str,GLint& value)
|
||||
else if (strcmp(str,"ADD_SIGNED")==0) value = TexEnvCombine::ADD_SIGNED;
|
||||
else if (strcmp(str,"INTERPOLATE")==0) value = TexEnvCombine::INTERPOLATE;
|
||||
else if (strcmp(str,"SUBTRACT")==0) value = TexEnvCombine::SUBTRACT;
|
||||
else if (strcmp(str,"DOT3_RGB")==0) value = TexEnvCombine::DOT3_RGB;
|
||||
else if (strcmp(str,"DOT3_RGBA")==0) value = TexEnvCombine::DOT3_RGBA;
|
||||
else return false;
|
||||
return true;
|
||||
}
|
||||
@@ -216,6 +218,8 @@ const char* TexEnvCombine_getCombineParamStr(GLint value)
|
||||
case(TexEnvCombine::ADD_SIGNED): return "ADD_SIGNED";
|
||||
case(TexEnvCombine::INTERPOLATE): return "INTERPOLATE";
|
||||
case(TexEnvCombine::SUBTRACT): return "SUBTRACT";
|
||||
case(TexEnvCombine::DOT3_RGB): return "DOT3_RGB";
|
||||
case(TexEnvCombine::DOT3_RGBA): return "DOT3_RGBA";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user