From 3ec6c6a4d9c2a351bfb4ad4e240483b3c70dac38 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 8 Jun 2009 13:47:25 +0000 Subject: [PATCH] Addded .ive and .osg support for new GL_EXT_blend_equation_separate properties in osg::BlendEquation --- src/osgPlugins/ive/BlendEquation.cpp | 21 ++++++++++++++++--- src/osgPlugins/ive/IveVersion.h | 3 ++- src/osgPlugins/osg/BlendEquation.cpp | 30 ++++++++++++++++++++++++---- 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/src/osgPlugins/ive/BlendEquation.cpp b/src/osgPlugins/ive/BlendEquation.cpp index 394ebb9c7..cc2f0e335 100644 --- a/src/osgPlugins/ive/BlendEquation.cpp +++ b/src/osgPlugins/ive/BlendEquation.cpp @@ -33,7 +33,15 @@ void BlendEquation::write(DataOutputStream* out){ // Write BlendEquation's properties. // Write source - out->writeInt(getEquation()); + if ( out->getVersion() >= VERSION_0040 ) + { + out->writeInt(getEquationRGB()); + out->writeInt(getEquationAlpha()); + } + else + { + out->writeInt(getEquation()); + } } void BlendEquation::read(DataInputStream* in){ @@ -52,8 +60,15 @@ void BlendEquation::read(DataInputStream* in){ // Read BlendEquation's properties // Read source - setEquation(osg::BlendEquation::Equation(in->readInt())); - + if ( in->getVersion() >= VERSION_0040 ) + { + setEquationRGB(osg::BlendEquation::Equation(in->readInt())); + setEquationAlpha(osg::BlendEquation::Equation(in->readInt())); + } + else + { + setEquation(osg::BlendEquation::Equation(in->readInt())); + } } else{ throw Exception("BlendEquation::read(): Expected BlendEquation identification."); diff --git a/src/osgPlugins/ive/IveVersion.h b/src/osgPlugins/ive/IveVersion.h index 454390c42..b0287616e 100644 --- a/src/osgPlugins/ive/IveVersion.h +++ b/src/osgPlugins/ive/IveVersion.h @@ -48,8 +48,9 @@ #define VERSION_0037 37 #define VERSION_0038 38 #define VERSION_0039 39 +#define VERSION_0040 40 -#define VERSION VERSION_0039 +#define VERSION VERSION_0040 /* The BYTE_SEX tag is used to check the endian of the IVE file being read in. The IVE format diff --git a/src/osgPlugins/osg/BlendEquation.cpp b/src/osgPlugins/osg/BlendEquation.cpp index ff1ff5060..32221eb3c 100644 --- a/src/osgPlugins/osg/BlendEquation.cpp +++ b/src/osgPlugins/osg/BlendEquation.cpp @@ -30,12 +30,26 @@ bool BlendEquation_readLocalData(Object& obj, Input& fr) { bool iteratorAdvanced = false; - BlendEquation& transparency = static_cast(obj); + BlendEquation& blendeq = static_cast(obj); int mode; if (fr[0].matchWord("equation") && BlendEquation_matchModeStr(fr[1].getStr(),mode)) { - transparency.setEquation(osg::BlendEquation::Equation(mode)); + blendeq.setEquation(osg::BlendEquation::Equation(mode)); + fr+=2; + iteratorAdvanced = true; + } + + if (fr[0].matchWord("equationRGB") && BlendEquation_matchModeStr(fr[1].getStr(),mode)) + { + blendeq.setEquationRGB(osg::BlendEquation::Equation(mode)); + fr+=2; + iteratorAdvanced = true; + } + + if (fr[0].matchWord("equationAlpha") && BlendEquation_matchModeStr(fr[1].getStr(),mode)) + { + blendeq.setEquationAlpha(osg::BlendEquation::Equation(mode)); fr+=2; iteratorAdvanced = true; } @@ -45,9 +59,17 @@ bool BlendEquation_readLocalData(Object& obj, Input& fr) bool BlendEquation_writeLocalData(const Object& obj, Output& fw) { - const BlendEquation& transparency = static_cast(obj); + const BlendEquation& blendeq = static_cast(obj); - fw.indent() << "equation " << BlendEquation_getModeStr(transparency.getEquation()) << std::endl; + if (blendeq.getEquationRGB()==blendeq.getEquationAlpha()) + { + fw.indent() << "equation " << BlendEquation_getModeStr(blendeq.getEquation()) << std::endl; + } + else + { + fw.indent() << "equationRGB " << BlendEquation_getModeStr(blendeq.getEquationRGB()) << std::endl; + fw.indent() << "equationAlpha " << BlendEquation_getModeStr(blendeq.getEquationAlpha()) << std::endl; + } return true; }