Added support for the tex_env_add and tex_env_crossbar extensions.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/GLExtensions>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
@@ -15,9 +16,20 @@ TexEnv::~TexEnv()
|
||||
|
||||
void TexEnv::apply(State&) const
|
||||
{
|
||||
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, _mode);
|
||||
if (_mode==TexEnv::BLEND)
|
||||
if (_mode==ADD)
|
||||
{
|
||||
glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, _color.ptr());
|
||||
static bool isTexEnvAddSupported = isGLExtensionSupported("GL_ARB_texture_env_add");
|
||||
if (isTexEnvAddSupported)
|
||||
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, ADD);
|
||||
else // fallback on OpenGL default.
|
||||
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, MODULATE);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, _mode);
|
||||
if (_mode==TexEnv::BLEND)
|
||||
{
|
||||
glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, _color.ptr());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
using namespace osg;
|
||||
|
||||
TexEnvCombine::TexEnvCombine():
|
||||
_needsTexEnvCrossbar(false),
|
||||
_combine_RGB(GL_MODULATE),
|
||||
_combine_Alpha(GL_MODULATE),
|
||||
_source0_RGB(GL_TEXTURE),
|
||||
@@ -33,7 +34,10 @@ void TexEnvCombine::apply(State&) const
|
||||
static bool isTexEnvCombineSupported =
|
||||
isGLExtensionSupported("GL_ARB_texture_env_combine");
|
||||
|
||||
if (isTexEnvCombineSupported)
|
||||
static bool isTexEnvCrossbarSupported =
|
||||
isGLExtensionSupported("GL_ARB_texture_env_crossbar");
|
||||
|
||||
if (isTexEnvCrossbarSupported || (!_needsTexEnvCrossbar && isTexEnvCombineSupported))
|
||||
{
|
||||
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ bool TexEnv_writeLocalData(const Object& obj, Output& fw)
|
||||
case(TexEnv::DECAL):
|
||||
case(TexEnv::MODULATE):
|
||||
case(TexEnv::REPLACE):
|
||||
case(TexEnv::ADD):
|
||||
break;
|
||||
case(TexEnv::BLEND):
|
||||
default:
|
||||
@@ -82,6 +83,7 @@ bool TexEnv_matchModeStr(const char* str,TexEnv::Mode& mode)
|
||||
else if (strcmp(str,"MODULATE")==0) mode = TexEnv::MODULATE;
|
||||
else if (strcmp(str,"BLEND")==0) mode = TexEnv::BLEND;
|
||||
else if (strcmp(str,"REPLACE")==0) mode = TexEnv::REPLACE;
|
||||
else if (strcmp(str,"ADD")==0) mode = TexEnv::ADD;
|
||||
else return false;
|
||||
return true;
|
||||
}
|
||||
@@ -95,6 +97,7 @@ const char* TexEnv_getModeStr(TexEnv::Mode mode)
|
||||
case(TexEnv::MODULATE): return "MODULATE";
|
||||
case(TexEnv::BLEND): return "BLEND";
|
||||
case(TexEnv::REPLACE): return "REPLACE";
|
||||
case(TexEnv::ADD): return "ADD";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user