diff --git a/VisualStudio/osg/osg.dsp b/VisualStudio/osg/osg.dsp index da1402c9d..47898d2e3 100755 --- a/VisualStudio/osg/osg.dsp +++ b/VisualStudio/osg/osg.dsp @@ -269,6 +269,10 @@ SOURCE=..\..\src\osg\Matrix.cpp # End Source File # Begin Source File +SOURCE=..\..\src\osg\MatrixTransform.cpp +# End Source File +# Begin Source File + SOURCE=..\..\src\osg\MemoryManager.cpp # End Source File # Begin Source File @@ -377,7 +381,7 @@ SOURCE=..\..\src\osg\Transform.cpp # End Source File # Begin Source File -SOURCE=..\..\src\osg\Transparency.cpp +SOURCE=..\..\src\osg\BlendFunc.cpp # End Source File # Begin Source File @@ -585,6 +589,10 @@ SOURCE=..\..\Include\Osg\Matrix # End Source File # Begin Source File +SOURCE=..\..\Include\Osg\MatrixTransform +# End Source File +# Begin Source File + SOURCE=..\..\include\osg\mem_ptr # End Source File # Begin Source File @@ -729,7 +737,7 @@ SOURCE=..\..\Include\Osg\Transform # End Source File # Begin Source File -SOURCE=..\..\Include\Osg\Transparency +SOURCE=..\..\Include\Osg\BlendFunc # End Source File # Begin Source File diff --git a/VisualStudio/osgPlugins/osg/dot_osg.dsp b/VisualStudio/osgPlugins/osg/dot_osg.dsp index 7818661e5..bdb28bf62 100755 --- a/VisualStudio/osgPlugins/osg/dot_osg.dsp +++ b/VisualStudio/osgPlugins/osg/dot_osg.dsp @@ -270,7 +270,7 @@ SOURCE=..\..\..\src\osgPlugins\osg\Transform.cpp # End Source File # Begin Source File -SOURCE=..\..\..\src\osgPlugins\osg\Transparency.cpp +SOURCE=..\..\..\src\osgPlugins\osg\BlendFunc.cpp # End Source File # End Group # Begin Group "Header Files" diff --git a/include/osg/BlendFunc b/include/osg/BlendFunc new file mode 100644 index 000000000..de49bcc00 --- /dev/null +++ b/include/osg/BlendFunc @@ -0,0 +1,84 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2001 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. + +#ifndef OSG_BLENDFUNC +#define OSG_BLENDFUNC 1 + +#include + +namespace osg { + +/** BlendFunc - encapsulates the OpenGL blend/transparency state.*/ +class SG_EXPORT BlendFunc : public StateAttribute +{ + public : + + BlendFunc(); + + /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ + BlendFunc(const BlendFunc& trans,const CopyOp& copyop=CopyOp::SHALLOW_COPY): + StateAttribute(trans,copyop), + _source_factor(trans._source_factor), + _destination_factor(trans._destination_factor) {} + + META_StateAttribute(osg, BlendFunc,BLENDFUNC); + + /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/ + virtual int compare(const StateAttribute& sa) const + { + // check the types are equal and then create the rhs variable + // used by the COMPARE_StateAttribute_Paramter macro's below. + COMPARE_StateAttribute_Types(BlendFunc,sa) + + // compare each paramter in turn against the rhs. + COMPARE_StateAttribute_Parameter(_source_factor) + COMPARE_StateAttribute_Parameter(_destination_factor) + + return 0; // passed all the above comparison macro's, must be equal. + } + + virtual void getAssociatedModes(std::vector& modes) const + { + modes.push_back(GL_BLEND); + } + + enum BlendFuncMode { + DST_ALPHA = GL_DST_ALPHA, + DST_COLOR = GL_DST_COLOR, + ONE = GL_ONE, + ONE_MINUS_DST_ALPHA = GL_ONE_MINUS_DST_ALPHA, + ONE_MINUS_DST_COLOR = GL_ONE_MINUS_DST_COLOR, + ONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA, + ONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR, + SRC_ALPHA = GL_SRC_ALPHA, + SRC_ALPHA_SATURATE = GL_SRC_ALPHA_SATURATE, + SRC_COLOR = GL_SRC_COLOR, + ZERO = GL_ZERO + }; + + inline void setFunction( const int source, const int destination ) + { + _source_factor = source; + _destination_factor = destination; + } + + void setSource(const int source) { _source_factor = source; } + inline const int getSource() const { return _source_factor; } + + void setDestination(const int destination) { _destination_factor = destination; } + inline const int getDestination() const { return _destination_factor; } + + virtual void apply(State& state) const; + + protected : + + virtual ~BlendFunc(); + + int _source_factor; + int _destination_factor; +}; + +} + +#endif diff --git a/include/osg/BoundingBox b/include/osg/BoundingBox index 0f12d05d0..fcab78456 100644 --- a/include/osg/BoundingBox +++ b/include/osg/BoundingBox @@ -50,8 +50,10 @@ class SG_EXPORT BoundingBox _max.set(-FLT_MAX,-FLT_MAX,-FLT_MAX); } +#ifdef USE_DEPRECATED_API /** deprecated, use valid() instead.*/ inline const bool isValid() const { return _max.x()>=_min.x(); } +#endif inline const bool valid() const { diff --git a/include/osg/BoundingSphere b/include/osg/BoundingSphere index d865c8d59..fc3c62330 100644 --- a/include/osg/BoundingSphere +++ b/include/osg/BoundingSphere @@ -38,9 +38,10 @@ class SG_EXPORT BoundingSphere _radius = -1.0f; } +#ifdef USE_DEPRECATED_API /** deprecated, use valid() instead.*/ inline const bool isValid() const { return _radius>=0.0f; } - +#endif /** return true if the bounding sphere contains valid values, false if the bounding sphere is effectively unset.*/ inline const bool valid() const { return _radius>=0.0f; } diff --git a/include/osg/Export b/include/osg/Export index 7527b40f1..bacd9c3e5 100644 --- a/include/osg/Export +++ b/include/osg/Export @@ -5,6 +5,11 @@ #ifndef OSG_EXPORT #define OSG_EXPORT 1 +// define used to include in API which is being fazed out +// if you can compile your apps with this turned off you are +// well placed for compatablity with future versions. +#define USE_DEPRECATED_API + #if defined(_MSC_VER) #pragma warning( disable : 4244 ) #pragma warning( disable : 4251 ) diff --git a/include/osg/StateAttribute b/include/osg/StateAttribute index c78708220..b2a106e8f 100644 --- a/include/osg/StateAttribute +++ b/include/osg/StateAttribute @@ -131,7 +131,7 @@ class SG_EXPORT StateAttribute : public Object TEXGEN, TEXMAT, LIGHTMODEL, - TRANSPARENCY, + BLENDFUNC, STENCIL, COLORMASK, DEPTH, diff --git a/include/osg/Transform b/include/osg/Transform index c7ccf7b6c..a721cd07b 100644 --- a/include/osg/Transform +++ b/include/osg/Transform @@ -36,8 +36,9 @@ class SG_EXPORT Transform : public Group /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ Transform(const Transform&,const CopyOp& copyop=CopyOp::SHALLOW_COPY); +#ifdef USE_DEPRECATED_API Transform(const Matrix& matix); - +#endif META_Node(osg, Transform); enum ReferenceFrame @@ -104,27 +105,59 @@ class SG_EXPORT Transform : public Group } +#ifndef USE_DEPRECATED_API + + virtual const bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const + { + if (_referenceFrame==RELATIVE_TO_ABSOLUTE) + { + return false; + } + else // absolute + { + matrix.makeIdent(); + return true; + } + } + + virtual const bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor*) const + { + if (_referenceFrame==RELATIVE_TO_ABSOLUTE) + { + return false; + } + else // absolute + { + matrix.makeIdent(); + return true; + } + } + + virtual const bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const { return false; } + +#else + /** Set the transform's matrix.*/ - void setMatrix(const Matrix& mat) { (*_matrix) = mat; _inverseDirty=true; computeInverse(); dirtyBound(); } + void setMatrix(const Matrix& mat) { (*_deprecated_matrix) = mat; _deprecated_inverseDirty=true; computeInverse(); dirtyBound(); } /** Get the transform's matrix. */ - inline const Matrix& getMatrix() const { return *_matrix; } + inline const Matrix& getMatrix() const { return *_deprecated_matrix; } /** preMult transform.*/ - void preMult(const Matrix& mat) { _matrix->preMult(mat); _inverseDirty=true; computeInverse(); dirtyBound(); } + void preMult(const Matrix& mat) { _deprecated_matrix->preMult(mat); _deprecated_inverseDirty=true; computeInverse(); dirtyBound(); } /** postMult transform.*/ - void postMult(const Matrix& mat) { _matrix->postMult(mat); _inverseDirty=true; computeInverse(); dirtyBound(); } + void postMult(const Matrix& mat) { _deprecated_matrix->postMult(mat); _deprecated_inverseDirty=true; computeInverse(); dirtyBound(); } virtual const bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const { if (_referenceFrame==RELATIVE_TO_PARENTS) { - matrix.preMult(*_matrix); + matrix.preMult(*_deprecated_matrix); } else // absolute { - matrix = *_matrix; + matrix = *_deprecated_matrix; } return true; } @@ -133,14 +166,16 @@ class SG_EXPORT Transform : public Group { if (_referenceFrame==RELATIVE_TO_PARENTS) { - matrix.postMult(*_inverse); + matrix.postMult(*_deprecated_inverse); } else // absolute { - matrix = *_inverse; + matrix = *_deprecated_inverse; } return true; } +#endif + protected : @@ -152,23 +187,26 @@ class SG_EXPORT Transform : public Group virtual const bool computeBound() const; - inline void computeInverse() const - { - if (_inverseDirty) - { - _inverse->invert(*_matrix); - _inverseDirty = false; - } - } - ref_ptr _computeTransformCallback; ReferenceFrame _referenceFrame; - ref_ptr _matrix; - mutable ref_ptr _inverse; - mutable bool _inverseDirty; + +#ifdef USE_DEPRECATED_API + inline void computeInverse() const + { + if (_deprecated_inverseDirty) + { + _deprecated_inverse->invert(*_deprecated_matrix); + _deprecated_inverseDirty = false; + } + } + + ref_ptr _deprecated_matrix; + mutable ref_ptr _deprecated_inverse; + mutable bool _deprecated_inverseDirty; +#endif }; diff --git a/include/osg/Transparency b/include/osg/Transparency index bb8afd601..854f02e3b 100644 --- a/include/osg/Transparency +++ b/include/osg/Transparency @@ -5,80 +5,13 @@ #ifndef OSG_TRANSPARENCY #define OSG_TRANSPARENCY 1 -#include +#include namespace osg { -/** Transparency - encapsulates the OpenGL blend/transparency state.*/ -class SG_EXPORT Transparency : public StateAttribute -{ - public : - - Transparency(); - - /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ - Transparency(const Transparency& trans,const CopyOp& copyop=CopyOp::SHALLOW_COPY): - StateAttribute(trans,copyop), - _source_factor(trans._source_factor), - _destination_factor(trans._destination_factor) {} - - META_StateAttribute(osg, Transparency,TRANSPARENCY); - - /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/ - virtual int compare(const StateAttribute& sa) const - { - // check the types are equal and then create the rhs variable - // used by the COMPARE_StateAttribute_Paramter macro's below. - COMPARE_StateAttribute_Types(Transparency,sa) - - // compare each paramter in turn against the rhs. - COMPARE_StateAttribute_Parameter(_source_factor) - COMPARE_StateAttribute_Parameter(_destination_factor) - - return 0; // passed all the above comparison macro's, must be equal. - } - - virtual void getAssociatedModes(std::vector& modes) const - { - modes.push_back(GL_BLEND); - } - - enum TransparencyMode { - DST_ALPHA = GL_DST_ALPHA, - DST_COLOR = GL_DST_COLOR, - ONE = GL_ONE, - ONE_MINUS_DST_ALPHA = GL_ONE_MINUS_DST_ALPHA, - ONE_MINUS_DST_COLOR = GL_ONE_MINUS_DST_COLOR, - ONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA, - ONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR, - SRC_ALPHA = GL_SRC_ALPHA, - SRC_ALPHA_SATURATE = GL_SRC_ALPHA_SATURATE, - SRC_COLOR = GL_SRC_COLOR, - ZERO = GL_ZERO - }; - - inline void setFunction( const int source, const int destination ) - { - _source_factor = source; - _destination_factor = destination; - } - - void setSource(const int source) { _source_factor = source; } - inline const int getSource() const { return _source_factor; } - - void setDestination(const int destination) { _destination_factor = destination; } - inline const int getDestination() const { return _destination_factor; } - - virtual void apply(State& state) const; - - protected : - - virtual ~Transparency(); - - int _source_factor; - int _destination_factor; -}; - +#ifdef USE_DEPRECATED_API +typedef BlendFunc Transparency; +#endif } #endif diff --git a/src/Demos/osghud/osghud.cpp b/src/Demos/osghud/osghud.cpp index 1848e8a2f..52939475a 100644 --- a/src/Demos/osghud/osghud.cpp +++ b/src/Demos/osghud/osghud.cpp @@ -183,7 +183,7 @@ void set2dScene(osg::Group* rootNode) textState->setAttribute(textMaterial ); textState->setAttribute(transp); - textState->setMode(GL_TEXTURE_2D,osg::StateAttribute::ON); + textState->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::ON); textState->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); geode->setStateSet( textState ); diff --git a/src/Demos/osgparticle/osgparticle.cpp b/src/Demos/osgparticle/osgparticle.cpp index b4f82202a..46432f5c1 100644 --- a/src/Demos/osgparticle/osgparticle.cpp +++ b/src/Demos/osgparticle/osgparticle.cpp @@ -340,9 +340,10 @@ void build_world(osg::Group *root) ////////////////////////////////////////////////////////////////////////////// -int main() +int main( int /*argc*/, char **argv ) { osgGLUT::Viewer viewer; + viewer.setWindowTitle(argv[0]); osg::Group *root = osgNew osg::Group; build_world(root); diff --git a/src/Demos/osgscribe/osgscribe.cpp b/src/Demos/osgscribe/osgscribe.cpp index 71ddf00c1..e3449dad9 100644 --- a/src/Demos/osgscribe/osgscribe.cpp +++ b/src/Demos/osgscribe/osgscribe.cpp @@ -119,8 +119,8 @@ int main( int argc, char **argv ) stateset->setAttributeAndModes(material,osg::StateAttribute::OVERRIDE_ON); stateset->setAttributeAndModes(polyoffset,osg::StateAttribute::OVERRIDE_ON); stateset->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE_ON); - stateset->setMode(GL_TEXTURE_2D,osg::StateAttribute::OVERRIDE_OFF); stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE_ON); + stateset->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OVERRIDE_OFF); // osg::LineStipple* linestipple = new osg::LineStipple; // linestipple->setFactor(1); diff --git a/src/Demos/osgtext/main.cpp b/src/Demos/osgtext/main.cpp index 43e444922..e2c608807 100644 --- a/src/Demos/osgtext/main.cpp +++ b/src/Demos/osgtext/main.cpp @@ -77,17 +77,11 @@ void set2dScene(osg::Group* rootNode) osgText::Text::BOUNDINGBOX | osgText::Text::ALIGNMENT ); text->setAlignment(gAlignment); + text->setColor(TEXT_COL_2D); geode = osgNew osg::Geode(); geode->setName("BitmapFont"); geode->addDrawable( text ); - textMaterial = osgNew osg::Material(); - textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE); - textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D); - textState = osgNew osg::StateSet(); - textState->setAttribute(textMaterial ); - geode->setStateSet( textState ); - rootNode->addChild(geode); xOffset+=90; @@ -105,24 +99,17 @@ void set2dScene(osg::Group* rootNode) osgText::Text::BOUNDINGBOX | osgText::Text::ALIGNMENT ); text->setAlignment(gAlignment); + text->setColor(TEXT_COL_2D); geode = osgNew osg::Geode(); geode->setName("PixmapFont"); geode->addDrawable( text ); - textMaterial = osgNew osg::Material(); - textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE); - textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_2D); // to get antiaA pixmapFonts we have to draw them with blending osg::Transparency *transp= osgNew osg::Transparency(); transp->setFunction(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); - - - textState = osgNew osg::StateSet(); - textState->setAttribute(textMaterial ); - textState->setAttribute(transp); - textState->setMode(GL_BLEND,osg::StateAttribute::ON); + textState->setAttributeAndModes(transp,osg::StateAttribute::ON); textState->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); @@ -145,22 +132,19 @@ void set2dScene(osg::Group* rootNode) osgText::Text::BOUNDINGBOX | osgText::Text::ALIGNMENT ); text->setAlignment(gAlignment); + text->setColor(TEXT_COL_2D); geode = osgNew osg::Geode(); geode->setName("TextureFont"); geode->addDrawable( text ); - textMaterial = osgNew osg::Material(); - textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE); - textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D); // to get antiaA pixmapFonts we have to draw them with blending transp= osgNew osg::Transparency(); transp->setFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); textState = osgNew osg::StateSet(); - textState->setAttribute(textMaterial ); - textState->setAttribute(transp); + textState->setAttributeAndModes(transp,osg::StateAttribute::ON); - textState->setMode(GL_TEXTURE_2D,osg::StateAttribute::ON); + textState->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::ON); textState->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); geode->setStateSet( textState ); @@ -182,17 +166,11 @@ void set2dScene(osg::Group* rootNode) osgText::Text::BOUNDINGBOX | osgText::Text::ALIGNMENT ); text->setAlignment(gAlignment); + text->setColor(TEXT_COL_2D); geode = osgNew osg::Geode(); geode->setName("PolygonFont"); geode->addDrawable( text ); - textMaterial = osgNew osg::Material(); - textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE); - textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D); - textState = osgNew osg::StateSet(); - textState->setAttribute(textMaterial ); - geode->setStateSet( textState ); - rootNode->addChild(geode); xOffset+=90; @@ -212,17 +190,11 @@ void set2dScene(osg::Group* rootNode) osgText::Text::BOUNDINGBOX | osgText::Text::ALIGNMENT ); text->setAlignment(gAlignment); + text->setColor(TEXT_COL_2D); geode = osgNew osg::Geode(); geode->setName("OutlineFont"); geode->addDrawable( text ); - textMaterial = osgNew osg::Material(); - textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE); - textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D); - textState = osgNew osg::StateSet(); - textState->setAttribute(textMaterial ); - geode->setStateSet( textState ); - rootNode->addChild(geode); @@ -337,7 +309,7 @@ void setScene(osg::Group* rootNode) textState->setAttribute(transp); // textState->setMode(GL_BLEND,osg::StateAttribute::ON); - textState->setMode(GL_TEXTURE_2D,osg::StateAttribute::ON); + textState->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::ON); textState->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); geode->setStateSet( textState ); diff --git a/src/osg/Transparency.cpp b/src/osg/BlendFunc.cpp similarity index 60% rename from src/osg/Transparency.cpp rename to src/osg/BlendFunc.cpp index 34814efe5..f6cf8a004 100644 --- a/src/osg/Transparency.cpp +++ b/src/osg/BlendFunc.cpp @@ -1,19 +1,19 @@ -#include +#include using namespace osg; -Transparency::Transparency() +BlendFunc::BlendFunc() { _source_factor = SRC_ALPHA; _destination_factor = ONE_MINUS_SRC_ALPHA; } -Transparency::~Transparency() +BlendFunc::~BlendFunc() { } -void Transparency::apply(State&) const +void BlendFunc::apply(State&) const { glBlendFunc( (GLenum)_source_factor, (GLenum)_destination_factor ); } diff --git a/src/osg/Makefile b/src/osg/Makefile index 788d102a4..501deb6b9 100644 --- a/src/osg/Makefile +++ b/src/osg/Makefile @@ -8,6 +8,7 @@ CXXFILES =\ Billboard.cpp\ BoundingBox.cpp\ BoundingSphere.cpp\ + BlendFunc.cpp\ Camera.cpp\ ClipNode.cpp\ ClipPlane.cpp\ @@ -73,7 +74,6 @@ CXXFILES =\ TextureCubeMap.cpp\ Timer.cpp\ Transform.cpp\ - Transparency.cpp\ Version.cpp\ Viewport.cpp\ diff --git a/src/osg/Transform.cpp b/src/osg/Transform.cpp index c8cd929aa..87e1b392e 100644 --- a/src/osg/Transform.cpp +++ b/src/osg/Transform.cpp @@ -6,30 +6,36 @@ Transform::Transform() { _referenceFrame = RELATIVE_TO_PARENTS; - _matrix = osgNew Matrix; - _inverse = osgNew Matrix; - _inverseDirty = false; +#ifdef USE_DEPRECATED_API + _deprecated_matrix = osgNew Matrix; + _deprecated_inverse = osgNew Matrix; + _deprecated_inverseDirty = false; +#endif } Transform::Transform(const Transform& transform,const CopyOp& copyop): Group(transform,copyop), _computeTransformCallback(transform._computeTransformCallback), - _referenceFrame(transform._referenceFrame), - _matrix(osgNew Matrix(*transform._matrix)), - _inverse(osgNew Matrix(*transform._inverse)), - _inverseDirty(transform._inverseDirty) + _referenceFrame(transform._referenceFrame) +#ifdef USE_DEPRECATED_API + , + _deprecated_matrix(osgNew Matrix(*transform._deprecated_matrix)), + _deprecated_inverse(osgNew Matrix(*transform._deprecated_inverse)), + _deprecated_inverseDirty(transform._deprecated_inverseDirty) +#endif { } +#ifdef USE_DEPRECATED_API Transform::Transform(const Matrix& mat ) { _referenceFrame = RELATIVE_TO_PARENTS; - _matrix = osgNew Matrix(mat); - _inverse = osgNew Matrix(); - _inverseDirty = false; + _deprecated_matrix = osgNew Matrix(mat); + _deprecated_inverse = osgNew Matrix(); + _deprecated_inverseDirty = false; } - +#endif Transform::~Transform() { diff --git a/src/osgPlugins/dw/ReaderWriterDW.cpp b/src/osgPlugins/dw/ReaderWriterDW.cpp index 729c70b46..860af5e5e 100644 --- a/src/osgPlugins/dw/ReaderWriterDW.cpp +++ b/src/osgPlugins/dw/ReaderWriterDW.cpp @@ -99,7 +99,7 @@ public: cf->setMode(osg::CullFace::BACK); dstate->setAttribute(cf); - dstate->setMode(GL_TEXTURE_2D,StateAttribute::OFF); + dstate->setTextureMode(0,GL_TEXTURE_2D,StateAttribute::OFF); settexture(); } return dstate; diff --git a/src/osgPlugins/dx/DXWriter.cpp b/src/osgPlugins/dx/DXWriter.cpp index 53da0ae7e..6aabfa3b0 100644 --- a/src/osgPlugins/dx/DXWriter.cpp +++ b/src/osgPlugins/dx/DXWriter.cpp @@ -2002,9 +2002,9 @@ void MyStateSet::Query( const osg::StateSet &sset ) } // TEXTURE / TEXTURE_0 - attr = sset.getAttribute( osg::StateAttribute::TEXTURE ); + attr = sset.getTextureAttribute(0, osg::StateAttribute::TEXTURE ); if ( attr && - ( sset.getMode( GL_TEXTURE_2D ) & osg::StateAttribute::ON )) { + ( sset.getTextureMode(0, GL_TEXTURE_2D ) & osg::StateAttribute::ON )) { const osg::Texture &texture = (const osg::Texture &) (*attr); @@ -2060,9 +2060,9 @@ void MyStateSet::Query( const osg::StateSet &sset ) } // TEXENV - attr = sset.getAttribute( osg::StateAttribute::TEXENV ); + attr = sset.getTextureAttribute(0, osg::StateAttribute::TEXENV ); if ( attr && - ( sset.getMode( GL_TEXTURE_2D ) & osg::StateAttribute::ON )) { + ( sset.getTextureMode(0, GL_TEXTURE_2D ) & osg::StateAttribute::ON )) { AddAttribute( osg::StateAttribute::TEXENV ); const osg::TexEnv &texenv = (const osg::TexEnv &) (*attr); @@ -2071,9 +2071,9 @@ void MyStateSet::Query( const osg::StateSet &sset ) } // TEXGEN - attr = sset.getAttribute( osg::StateAttribute::TEXGEN ); + attr = sset.getTextureAttribute(0, osg::StateAttribute::TEXGEN ); if ( attr && - ( sset.getMode( GL_TEXTURE_2D ) & osg::StateAttribute::ON )) { + ( sset.getTextureMode(0, GL_TEXTURE_2D ) & osg::StateAttribute::ON )) { // FIXME: Just note that it is there for now. We don't actually support // texture coordinate generation yet (i.e. generating the "uv" component diff --git a/src/osgPlugins/dx/StateSetStr.cpp b/src/osgPlugins/dx/StateSetStr.cpp index 874170800..a15ca6d35 100644 --- a/src/osgPlugins/dx/StateSetStr.cpp +++ b/src/osgPlugins/dx/StateSetStr.cpp @@ -118,7 +118,7 @@ static void initOSGAttrNames() ADD_ATTR( osg::StateAttribute::TEXENV , "TEXENV" ); ADD_ATTR( osg::StateAttribute::TEXGEN , "TEXGEN" ); ADD_ATTR( osg::StateAttribute::TEXMAT , "TEXMAT" ); - ADD_ATTR( osg::StateAttribute::TRANSPARENCY , "TRANSPARENCY" ); + ADD_ATTR( osg::StateAttribute::BLENDFUNC , "BLENDFUNC" ); ADD_ATTR( osg::StateAttribute::STENCIL , "STENCIL" ); ADD_ATTR( osg::StateAttribute::COLORMASK , "COLORMASK" ); ADD_ATTR( osg::StateAttribute::DEPTH , "DEPTH" ); diff --git a/src/osgPlugins/osg/BlendFunc.cpp b/src/osgPlugins/osg/BlendFunc.cpp new file mode 100644 index 000000000..944e655ad --- /dev/null +++ b/src/osgPlugins/osg/BlendFunc.cpp @@ -0,0 +1,107 @@ +#include "osg/BlendFunc" + +#include "osgDB/Registry" +#include "osgDB/Input" +#include "osgDB/Output" + +using namespace osg; +using namespace osgDB; + +// forward declare functions to use later. +bool BlendFunc_readLocalData(Object& obj, Input& fr); +bool BlendFunc_writeLocalData(const Object& obj, Output& fw); + +bool BlendFunc_matchModeStr(const char* str,int& mode); +const char* BlendFunc_getModeStr(int value); + +// register the read and write functions with the osgDB::Registry. +RegisterDotOsgWrapperProxy g_BlendFuncProxy +( + osgNew osg::BlendFunc, + "BlendFunc", + "Object StateAttribute BlendFunc", + &BlendFunc_readLocalData, + &BlendFunc_writeLocalData +); + +RegisterDotOsgWrapperProxy g_TransparencyProxy +( + osgNew osg::BlendFunc, + "Transparancy", + "Object StateAttribute Transparency", + &BlendFunc_readLocalData, + &BlendFunc_writeLocalData +); + +bool BlendFunc_readLocalData(Object& obj, Input& fr) +{ + bool iteratorAdvanced = false; + + BlendFunc& transparency = static_cast(obj); + + int mode; + if (fr[0].matchWord("source") && BlendFunc_matchModeStr(fr[1].getStr(),mode)) + { + transparency.setSource(mode); + fr+=2; + iteratorAdvanced = true; + } + + if (fr[0].matchWord("destination") && BlendFunc_matchModeStr(fr[1].getStr(),mode)) + { + transparency.setDestination(mode); + fr+=2; + iteratorAdvanced = true; + } + + return iteratorAdvanced; +} + +bool BlendFunc_writeLocalData(const Object& obj, Output& fw) +{ + const BlendFunc& transparency = static_cast(obj); + + fw.indent() << "source " << BlendFunc_getModeStr(transparency.getSource()) << std::endl; + fw.indent() << "destination " << BlendFunc_getModeStr(transparency.getDestination()) << std::endl; + + return true; +} + + + +bool BlendFunc_matchModeStr(const char* str,int& mode) +{ + if (strcmp(str,"DST_ALPHA")==0) mode = BlendFunc::DST_ALPHA; + else if (strcmp(str,"DST_COLOR")==0) mode = BlendFunc::DST_COLOR; + else if (strcmp(str,"ONE")==0) mode = BlendFunc::ONE; + else if (strcmp(str,"ONE_MINUS_DST_ALPHA")==0) mode = BlendFunc::ONE_MINUS_DST_ALPHA; + else if (strcmp(str,"ONE_MINUS_DST_COLOR")==0) mode = BlendFunc::ONE_MINUS_DST_COLOR; + else if (strcmp(str,"ONE_MINUS_SRC_ALPHA")==0) mode = BlendFunc::ONE_MINUS_SRC_ALPHA; + else if (strcmp(str,"ONE_MINUS_SRC_COLOR")==0) mode = BlendFunc::ONE_MINUS_SRC_COLOR; + else if (strcmp(str,"SRC_ALPHA")==0) mode = BlendFunc::SRC_ALPHA; + else if (strcmp(str,"SRC_ALPHA_SATURATE")==0) mode = BlendFunc::SRC_ALPHA_SATURATE; + else if (strcmp(str,"SRC_COLOR")==0) mode = BlendFunc::SRC_COLOR; + else return false; + return true; + +} + +const char* BlendFunc_getModeStr(int value) +{ + switch(value) + { + case(BlendFunc::DST_ALPHA) : return "DST_ALPHA"; + case(BlendFunc::DST_COLOR) : return "DST_COLOR"; + case(BlendFunc::ONE) : return "ONE"; + case(BlendFunc::ONE_MINUS_DST_ALPHA) : return "ONE_MINUS_DST_ALPHA"; + case(BlendFunc::ONE_MINUS_DST_COLOR) : return "ONE_MINUS_DST_COLOR"; + case(BlendFunc::ONE_MINUS_SRC_ALPHA) : return "ONE_MINUS_SRC_ALPHA"; + case(BlendFunc::ONE_MINUS_SRC_COLOR) : return "ONE_MINUS_SRC_COLOR"; + case(BlendFunc::SRC_ALPHA) : return "SRC_ALPHA"; + case(BlendFunc::SRC_ALPHA_SATURATE) : return "SRC_ALPHA_SATURATE"; + case(BlendFunc::SRC_COLOR) : return "SRC_COLOR"; + case(BlendFunc::ZERO) : return "ZERO"; + } + + return NULL; +} diff --git a/src/osgPlugins/osg/Makefile b/src/osgPlugins/osg/Makefile index 613c655a7..31e1480fb 100644 --- a/src/osgPlugins/osg/Makefile +++ b/src/osgPlugins/osg/Makefile @@ -4,6 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ AlphaFunc.cpp\ Billboard.cpp\ + BlendFunc.cpp\ ClipPlane.cpp\ ColorMask.cpp\ ConvexPlanerOccluder.cpp\ @@ -44,7 +45,7 @@ CXXFILES =\ TexMat.cpp\ Texture.cpp\ Transform.cpp\ - Transparency.cpp\ + LIBS += $(OSG_LIBS) $(OTHER_LIBS) diff --git a/src/osgPlugins/osg/Transparency.cpp b/src/osgPlugins/osg/Transparency.cpp deleted file mode 100644 index 0e38ada32..000000000 --- a/src/osgPlugins/osg/Transparency.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include "osg/Transparency" - -#include "osgDB/Registry" -#include "osgDB/Input" -#include "osgDB/Output" - -using namespace osg; -using namespace osgDB; - -// forward declare functions to use later. -bool Transparency_readLocalData(Object& obj, Input& fr); -bool Transparency_writeLocalData(const Object& obj, Output& fw); - -bool Transparency_matchModeStr(const char* str,int& mode); -const char* Transparency_getModeStr(int value); - -// register the read and write functions with the osgDB::Registry. -RegisterDotOsgWrapperProxy g_TransparencyProxy -( - osgNew osg::Transparency, - "Transparency", - "Object StateAttribute Transparency", - &Transparency_readLocalData, - &Transparency_writeLocalData -); - - -bool Transparency_readLocalData(Object& obj, Input& fr) -{ - bool iteratorAdvanced = false; - - Transparency& transparency = static_cast(obj); - - int mode; - if (fr[0].matchWord("source") && Transparency_matchModeStr(fr[1].getStr(),mode)) - { - transparency.setSource(mode); - fr+=2; - iteratorAdvanced = true; - } - - if (fr[0].matchWord("destination") && Transparency_matchModeStr(fr[1].getStr(),mode)) - { - transparency.setDestination(mode); - fr+=2; - iteratorAdvanced = true; - } - - return iteratorAdvanced; -} - -bool Transparency_writeLocalData(const Object& obj, Output& fw) -{ - const Transparency& transparency = static_cast(obj); - - fw.indent() << "source " << Transparency_getModeStr(transparency.getSource()) << std::endl; - fw.indent() << "destination " << Transparency_getModeStr(transparency.getDestination()) << std::endl; - - return true; -} - - - -bool Transparency_matchModeStr(const char* str,int& mode) -{ - if (strcmp(str,"DST_ALPHA")==0) mode = Transparency::DST_ALPHA; - else if (strcmp(str,"DST_COLOR")==0) mode = Transparency::DST_COLOR; - else if (strcmp(str,"ONE")==0) mode = Transparency::ONE; - else if (strcmp(str,"ONE_MINUS_DST_ALPHA")==0) mode = Transparency::ONE_MINUS_DST_ALPHA; - else if (strcmp(str,"ONE_MINUS_DST_COLOR")==0) mode = Transparency::ONE_MINUS_DST_COLOR; - else if (strcmp(str,"ONE_MINUS_SRC_ALPHA")==0) mode = Transparency::ONE_MINUS_SRC_ALPHA; - else if (strcmp(str,"ONE_MINUS_SRC_COLOR")==0) mode = Transparency::ONE_MINUS_SRC_COLOR; - else if (strcmp(str,"SRC_ALPHA")==0) mode = Transparency::SRC_ALPHA; - else if (strcmp(str,"SRC_ALPHA_SATURATE")==0) mode = Transparency::SRC_ALPHA_SATURATE; - else if (strcmp(str,"SRC_COLOR")==0) mode = Transparency::SRC_COLOR; - else return false; - return true; - -} - -const char* Transparency_getModeStr(int value) -{ - switch(value) - { - case(Transparency::DST_ALPHA) : return "DST_ALPHA"; - case(Transparency::DST_COLOR) : return "DST_COLOR"; - case(Transparency::ONE) : return "ONE"; - case(Transparency::ONE_MINUS_DST_ALPHA) : return "ONE_MINUS_DST_ALPHA"; - case(Transparency::ONE_MINUS_DST_COLOR) : return "ONE_MINUS_DST_COLOR"; - case(Transparency::ONE_MINUS_SRC_ALPHA) : return "ONE_MINUS_SRC_ALPHA"; - case(Transparency::ONE_MINUS_SRC_COLOR) : return "ONE_MINUS_SRC_COLOR"; - case(Transparency::SRC_ALPHA) : return "SRC_ALPHA"; - case(Transparency::SRC_ALPHA_SATURATE) : return "SRC_ALPHA_SATURATE"; - case(Transparency::SRC_COLOR) : return "SRC_COLOR"; - case(Transparency::ZERO) : return "ZERO"; - } - - return NULL; -} diff --git a/src/osgPlugins/pfb/ConvertFromPerformer.cpp b/src/osgPlugins/pfb/ConvertFromPerformer.cpp index 7b08f7e03..a98962430 100644 --- a/src/osgPlugins/pfb/ConvertFromPerformer.cpp +++ b/src/osgPlugins/pfb/ConvertFromPerformer.cpp @@ -790,15 +790,15 @@ osg::StateSet* ConvertFromPerformer::visitGeoState(osg::Drawable* osgDrawable,pf } } - if (inherit & PFSTATE_ENTEXTURE) osgStateSet->setMode(GL_TEXTURE_2D,osg::StateAttribute::INHERIT); + if (inherit & PFSTATE_ENTEXTURE) osgStateSet->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::INHERIT); else { int mode = geostate->getMode(PFSTATE_ENTEXTURE); switch(mode) { - case(PF_ON): osgStateSet->setMode(GL_TEXTURE_2D,osg::StateAttribute::ON);break; + case(PF_ON): osgStateSet->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::ON);break; case(PF_OFF): - default: osgStateSet->setMode(GL_TEXTURE_2D,osg::StateAttribute::OFF);break; + default: osgStateSet->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OFF);break; } }