Added IO Support for TexEnvCombine state attribute.

This commit is contained in:
Robert Osfield 2002-08-20 18:00:22 +00:00
parent 88f387810d
commit 814dcc9677
5 changed files with 308 additions and 12 deletions

9
NEWS
View File

@ -2,6 +2,15 @@
OSG News (most significant items from ChangeLog)
================================================
Support for OpenFlight15.7 added.
Improved osgbillboard example.
Improved osglight example utilizing AnimationPath and PositionAttitudeTransform.
osg::TexEnvCombine implemented texture_env_combine and texture_env_crossbar.
osg::TexEnv texture_env_add added.
osg::Sequence implemented.
osg::DOFTransformNode implemented.
osg::AnimationPath improved.
July 2002 - OpenSceneGraph-0.9.0.tar.gz
>>> OpenSceneGraph goes beta - Multitexturing, Occlusion Culling, Particles and much more added!

View File

@ -262,6 +262,10 @@ SOURCE=..\..\..\src\osgPlugins\osg\TexEnv.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\osg\TexEnvCombine.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\osg\TexGen.cpp
# End Source File
# Begin Source File

View File

@ -119,11 +119,11 @@ class SG_EXPORT TexEnvCombine : public StateAttribute
SUBTRACT = GL_SUBTRACT_ARB
};
void setCombineRGB(GLint cm) { _combine_RGB = cm; }
void setCombineAlpha(GLint cm) { _combine_Alpha = cm; }
void setCombine_RGB(GLint cm) { _combine_RGB = cm; }
void setCombine_Alpha(GLint cm) { _combine_Alpha = cm; }
GLint getCombineRGB() const { return _combine_RGB; }
GLint getCombineAlpha() const { return _combine_Alpha; }
GLint getCombine_RGB() const { return _combine_RGB; }
GLint getCombine_Alpha() const { return _combine_Alpha; }
enum SourceParam
{
@ -131,14 +131,14 @@ class SG_EXPORT TexEnvCombine : public StateAttribute
PRIMARY_COLOR = GL_PRIMARY_COLOR_ARB,
PREVIOUS = GL_PREVIOUS_ARB,
TEXTURE = GL_TEXTURE,
TEXTURE_0 = GL_TEXTURE0,
TEXTURE_1 = GL_TEXTURE0+1,
TEXTURE_2 = GL_TEXTURE0+2,
TEXTURE_3 = GL_TEXTURE0+3,
TEXTURE_4 = GL_TEXTURE0+4,
TEXTURE_5 = GL_TEXTURE0+5,
TEXTURE_6 = GL_TEXTURE0+6,
TEXTURE_7 = GL_TEXTURE0+7
TEXTURE0 = GL_TEXTURE0,
TEXTURE1 = GL_TEXTURE0+1,
TEXTURE2 = GL_TEXTURE0+2,
TEXTURE3 = GL_TEXTURE0+3,
TEXTURE4 = GL_TEXTURE0+4,
TEXTURE5 = GL_TEXTURE0+5,
TEXTURE6 = GL_TEXTURE0+6,
TEXTURE7 = GL_TEXTURE0+7
};
void setSource0_RGB(GLint sp) { _source0_RGB = sp; computeNeedoForTexEnvCombiners(); }

View File

@ -45,6 +45,7 @@ CXXFILES =\
Stencil.cpp\
Switch.cpp\
TexEnv.cpp\
TexEnvCombine.cpp\
TexGen.cpp\
TexMat.cpp\
Texture.cpp\

View File

@ -0,0 +1,282 @@
#include "osg/TexEnvCombine"
#include "osgDB/Registry"
#include "osgDB/Input"
#include "osgDB/Output"
using namespace osg;
using namespace osgDB;
// forward declare functions to use later.
bool TexEnvCombine_readLocalData(Object& obj, Input& fr);
bool TexEnvCombine_writeLocalData(const Object& obj, Output& fw);
bool TexEnvCombine_matchCombineParamStr(const char* str,GLint& value);
const char* TexEnvCombine_getCombineParamStr(GLint value);
bool TexEnvCombine_matchSourceParamStr(const char* str,GLint& value);
const char* TexEnvCombine_getSourceParamStr(GLint value);
bool TexEnvCombine_matchOperandParamStr(const char* str,GLint& value);
const char* TexEnvCombine_getOperandParamStr(GLint value);
// register the read and write functions with the osgDB::Registry.
RegisterDotOsgWrapperProxy g_TexEnvCombineProxy
(
osgNew osg::TexEnvCombine,
"TexEnvCombine",
"Object StateAttribute TexEnvCombine",
&TexEnvCombine_readLocalData,
&TexEnvCombine_writeLocalData
);
bool TexEnvCombine_readLocalData(Object& obj, Input& fr)
{
bool iteratorAdvanced = false;
TexEnvCombine& texenv = static_cast<TexEnvCombine&>(obj);
GLint value;
if (fr[0].matchWord("combine_RGB") && TexEnvCombine_matchCombineParamStr(fr[1].getStr(),value))
{
texenv.setCombine_RGB(value);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("combine_Alpha") && TexEnvCombine_matchCombineParamStr(fr[1].getStr(),value))
{
texenv.setCombine_Alpha(value);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("source0_RGB") && TexEnvCombine_matchSourceParamStr(fr[1].getStr(),value))
{
texenv.setSource0_RGB(value);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("source1_RGB") && TexEnvCombine_matchSourceParamStr(fr[1].getStr(),value))
{
texenv.setSource1_RGB(value);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("source2_RGB") && TexEnvCombine_matchSourceParamStr(fr[1].getStr(),value))
{
texenv.setSource2_RGB(value);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("source0_Alpha") && TexEnvCombine_matchSourceParamStr(fr[1].getStr(),value))
{
texenv.setSource0_Alpha(value);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("source1_Alpha") && TexEnvCombine_matchSourceParamStr(fr[1].getStr(),value))
{
texenv.setSource1_Alpha(value);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("source2_Alpha") && TexEnvCombine_matchSourceParamStr(fr[1].getStr(),value))
{
texenv.setSource2_Alpha(value);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("operand0_RGB") && TexEnvCombine_matchOperandParamStr(fr[1].getStr(),value))
{
texenv.setOperand0_RGB(value);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("operand1_RGB") && TexEnvCombine_matchOperandParamStr(fr[1].getStr(),value))
{
texenv.setOperand1_RGB(value);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("operand2_RGB") && TexEnvCombine_matchOperandParamStr(fr[1].getStr(),value))
{
texenv.setOperand2_RGB(value);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("operand0_Alpha") && TexEnvCombine_matchOperandParamStr(fr[1].getStr(),value))
{
texenv.setOperand0_Alpha(value);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("operand1_Alpha") && TexEnvCombine_matchOperandParamStr(fr[1].getStr(),value))
{
texenv.setOperand1_Alpha(value);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("operand2_Alpha") && TexEnvCombine_matchOperandParamStr(fr[1].getStr(),value))
{
texenv.setOperand2_Alpha(value);
fr+=2;
iteratorAdvanced = true;
}
float scale;
if (fr[0].matchWord("scale_RGB") && fr[1].getFloat(scale))
{
texenv.setScale_RGB(scale);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("scale_Alpha") && fr[1].getFloat(scale))
{
texenv.setScale_Alpha(scale);
fr+=2;
iteratorAdvanced = true;
}
if (fr.matchSequence("constantColor %f %f %f %f"))
{
osg::Vec4 color;
fr[1].getFloat(color[0]);
fr[2].getFloat(color[1]);
fr[3].getFloat(color[2]);
fr[4].getFloat(color[3]);
texenv.setConstantColor(color);
fr+=5;
iteratorAdvanced = true;
}
return iteratorAdvanced;
}
bool TexEnvCombine_writeLocalData(const Object& obj, Output& fw)
{
const TexEnvCombine& texenv = static_cast<const TexEnvCombine&>(obj);
fw.indent() << "combine_RGB " << TexEnvCombine_getCombineParamStr(texenv.getCombine_RGB()) << std::endl;
fw.indent() << "combine_Alpha " << TexEnvCombine_getCombineParamStr(texenv.getCombine_Alpha()) << std::endl;
fw.indent() << "source0_RGB " << TexEnvCombine_getSourceParamStr(texenv.getSource0_RGB()) << std::endl;
fw.indent() << "source1_RGB " << TexEnvCombine_getSourceParamStr(texenv.getSource1_RGB()) << std::endl;
fw.indent() << "source2_RGB " << TexEnvCombine_getSourceParamStr(texenv.getSource2_RGB()) << std::endl;
fw.indent() << "source0_Alpha " << TexEnvCombine_getSourceParamStr(texenv.getSource0_Alpha()) << std::endl;
fw.indent() << "source1_Alpha " << TexEnvCombine_getSourceParamStr(texenv.getSource1_Alpha()) << std::endl;
fw.indent() << "source2_Alpha " << TexEnvCombine_getSourceParamStr(texenv.getSource2_Alpha()) << std::endl;
fw.indent() << "operand0_RGB " << TexEnvCombine_getOperandParamStr(texenv.getOperand0_RGB()) << std::endl;
fw.indent() << "operand1_RGB " << TexEnvCombine_getOperandParamStr(texenv.getOperand1_RGB()) << std::endl;
fw.indent() << "operand2_RGB " << TexEnvCombine_getOperandParamStr(texenv.getOperand2_RGB()) << std::endl;
fw.indent() << "operand0_Alpha " << TexEnvCombine_getOperandParamStr(texenv.getOperand0_Alpha()) << std::endl;
fw.indent() << "operand1_Alpha " << TexEnvCombine_getOperandParamStr(texenv.getOperand1_Alpha()) << std::endl;
fw.indent() << "operand2_Alpha " << TexEnvCombine_getOperandParamStr(texenv.getOperand2_Alpha()) << std::endl;
fw.indent() << "scale_RGB " << texenv.getScale_RGB() << std::endl;
fw.indent() << "scale_Alpha " << texenv.getScale_Alpha() << std::endl;
fw.indent() << "constantColor " << texenv.getConstantColor() << std::endl;
return true;
}
bool TexEnvCombine_matchCombineParamStr(const char* str,GLint& value)
{
if (strcmp(str,"REPLACE")==0) value = TexEnvCombine::REPLACE;
else if (strcmp(str,"MODULATE")==0) value = TexEnvCombine::MODULATE;
else if (strcmp(str,"ADD")==0) value = TexEnvCombine::ADD;
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 return false;
return true;
}
const char* TexEnvCombine_getCombineParamStr(GLint value)
{
switch(value)
{
case(TexEnvCombine::REPLACE): return "REPLACE";
case(TexEnvCombine::MODULATE): return "MODULATE";
case(TexEnvCombine::ADD): return "ADD";
case(TexEnvCombine::ADD_SIGNED): return "ADD_SIGNED";
case(TexEnvCombine::INTERPOLATE): return "INTERPOLATE";
case(TexEnvCombine::SUBTRACT): return "SUBTRACT";
}
return "";
}
bool TexEnvCombine_matchSourceParamStr(const char* str,GLint& value)
{
if (strcmp(str,"CONSTANT")==0) value = TexEnvCombine::CONSTANT;
else if (strcmp(str,"PRIMARY_COLOR")==0) value = TexEnvCombine::PRIMARY_COLOR;
else if (strcmp(str,"PREVIOUS")==0) value = TexEnvCombine::PREVIOUS;
else if (strcmp(str,"TEXTURE")==0) value = TexEnvCombine::TEXTURE;
else if (strcmp(str,"TEXTURE0")==0) value = TexEnvCombine::TEXTURE0;
else if (strcmp(str,"TEXTURE1")==0) value = TexEnvCombine::TEXTURE1;
else if (strcmp(str,"TEXTURE2")==0) value = TexEnvCombine::TEXTURE2;
else if (strcmp(str,"TEXTURE3")==0) value = TexEnvCombine::TEXTURE3;
else if (strcmp(str,"TEXTURE4")==0) value = TexEnvCombine::TEXTURE4;
else if (strcmp(str,"TEXTURE5")==0) value = TexEnvCombine::TEXTURE5;
else if (strcmp(str,"TEXTURE6")==0) value = TexEnvCombine::TEXTURE6;
else if (strcmp(str,"TEXTURE7")==0) value = TexEnvCombine::TEXTURE7;
else return false;
return true;
}
const char* TexEnvCombine_getSourceParamStr(GLint value)
{
switch(value)
{
case(TexEnvCombine::CONSTANT): return "CONSTANT";
case(TexEnvCombine::PRIMARY_COLOR): return "PRIMARY_COLOR";
case(TexEnvCombine::PREVIOUS): return "PREVIOUS";
case(TexEnvCombine::TEXTURE): return "TEXTURE";
case(TexEnvCombine::TEXTURE0): return "TEXTURE0";
case(TexEnvCombine::TEXTURE1): return "TEXTURE1";
case(TexEnvCombine::TEXTURE2): return "TEXTURE2";
case(TexEnvCombine::TEXTURE3): return "TEXTURE3";
case(TexEnvCombine::TEXTURE4): return "TEXTURE4";
case(TexEnvCombine::TEXTURE5): return "TEXTURE5";
case(TexEnvCombine::TEXTURE6): return "TEXTURE6";
case(TexEnvCombine::TEXTURE7): return "TEXTURE7";
}
return "";
}
bool TexEnvCombine_matchOperandParamStr(const char* str,GLint& value)
{
if (strcmp(str,"SRC_COLOR")==0) value = TexEnvCombine::SRC_COLOR;
else if (strcmp(str,"ONE_MINUS_SRC_COLOR")==0) value = TexEnvCombine::ONE_MINUS_SRC_COLOR;
else if (strcmp(str,"SRC_ALPHA")==0) value = TexEnvCombine::SRC_ALPHA;
else if (strcmp(str,"ONE_MINUS_SRC_ALPHA")==0) value = TexEnvCombine::ONE_MINUS_SRC_ALPHA;
else return false;
return true;
}
const char* TexEnvCombine_getOperandParamStr(GLint value)
{
switch(value)
{
case(TexEnvCombine::SRC_COLOR): return "SRC_COLOR";
case(TexEnvCombine::ONE_MINUS_SRC_COLOR): return "ONE_MINUS_SRC_COLOR";
case(TexEnvCombine::SRC_ALPHA): return "SRC_ALPHA";
case(TexEnvCombine::ONE_MINUS_SRC_ALPHA): return "ONE_MINUS_SRC_ALPHA";
}
return "";
}