diff --git a/include/osg/BlendEquation b/include/osg/BlendEquation index 83af8a7b3..612dfd85f 100644 --- a/include/osg/BlendEquation +++ b/include/osg/BlendEquation @@ -110,6 +110,9 @@ class OSG_EXPORT BlendEquation : public StateAttribute void (GL_APIENTRY * glBlendEquation)(GLenum mode); void (GL_APIENTRY * glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha); + + void (GL_APIENTRY * glBlendEquationi)(GLuint buf, GLenum mode); + void (GL_APIENTRY * glBlendEquationSeparatei)(GLuint buf, GLenum modeRGB, GLenum modeAlpha); }; protected : diff --git a/include/osg/BlendEquationi b/include/osg/BlendEquationi new file mode 100644 index 000000000..8ab85f6e0 --- /dev/null +++ b/include/osg/BlendEquationi @@ -0,0 +1,78 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef OSG_BLENDEQUATIONI +#define OSG_BLENDEQUATIONI 1 + +#include + +namespace osg { + +/** Encapsulates glBlendEquationi function : the index version of glBlendEquation for multiple render target. +*/ +class OSG_EXPORT BlendEquationi : public BlendEquation +{ + public : + + BlendEquationi(); + + BlendEquationi(unsigned int buf, Equation equation): + BlendEquation(equation), + _index(buf) {} + + BlendEquationi(unsigned int buf, Equation equationRGB, Equation equationAlpha): + BlendEquation(equationRGB, equationAlpha), + _index(buf) {} + + + /** Copy constructor using CopyOp to manage deep vs shallow copy. */ + BlendEquationi(const BlendEquationi& cm,const CopyOp& copyop=CopyOp::SHALLOW_COPY): + BlendEquation(cm,copyop), + _index(cm._index) {} + + META_StateAttribute(osg, BlendEquationi, BLENDEQUATION); + + /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */ + virtual int compare(const StateAttribute& sa) const + { + // Check for equal types, then create the rhs variable + // used by the COMPARE_StateAttribute_Parameter macros below. + COMPARE_StateAttribute_Types(BlendEquationi,sa) + + COMPARE_StateAttribute_Parameter(_index); + + return BlendEquation::compare(sa); + } + + /** Return the buffer index as the member identifier.*/ + virtual unsigned int getMember() const { return _index; } + + /** Set the renderbuffer index of the BlendEquationi. */ + void setIndex(unsigned int buf) { _index = buf; } + + /** Get the renderbuffer index of the BlendEquationi. */ + unsigned int getIndex() const { return _index; } + + virtual void apply(State& state) const; + + protected: + + virtual ~BlendEquationi(); + + unsigned int _index; + +}; + +} + +#endif diff --git a/include/osg/BlendFunc b/include/osg/BlendFunc index a57e2e7d4..ac5dbe2ce 100644 --- a/include/osg/BlendFunc +++ b/include/osg/BlendFunc @@ -15,8 +15,6 @@ #define OSG_BLENDFUNC 1 #include -#include - #ifndef GL_VERSION_1_2 #define GL_CONSTANT_COLOR 0x8001 @@ -166,6 +164,9 @@ class OSG_EXPORT BlendFunc : public StateAttribute bool isBlendFuncSeparateSupported; void (GL_APIENTRY * glBlendFuncSeparate) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) ; + + void (GL_APIENTRY * glBlendFunci) (GLuint buf, GLenum src, GLenum dst); + void (GL_APIENTRY * glBlendFuncSeparatei) (GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) ; }; diff --git a/include/osg/BlendFunci b/include/osg/BlendFunci new file mode 100644 index 000000000..a1ed108ed --- /dev/null +++ b/include/osg/BlendFunci @@ -0,0 +1,77 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef OSG_BLENDFUNCI +#define OSG_BLENDFUNCI 1 + +#include + +namespace osg { + +/** Encapsulates glBlendFunci function : the index version of glBlendEquation for multiple render target. +*/ +class OSG_EXPORT BlendFunci : public BlendFunc +{ + public : + + BlendFunci(); + + BlendFunci(unsigned int buf, GLenum source, GLenum destination): + BlendFunc(source, destination), + _index(buf) {} + + BlendFunci(unsigned int buf, GLenum source, GLenum destination, GLenum source_alpha, GLenum destination_alpha): + BlendFunc(source, destination, source_alpha, destination_alpha), + _index(buf) {} + + /** Copy constructor using CopyOp to manage deep vs shallow copy. */ + BlendFunci(const BlendFunci& cm,const CopyOp& copyop=CopyOp::SHALLOW_COPY): + BlendFunc(cm,copyop), + _index(cm._index) {} + + META_StateAttribute(osg, BlendFunci, BLENDFUNC); + + /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */ + virtual int compare(const StateAttribute& sa) const + { + // Check for equal types, then create the rhs variable + // used by the COMPARE_StateAttribute_Parameter macros below. + COMPARE_StateAttribute_Types(BlendFunci,sa) + + COMPARE_StateAttribute_Parameter(_index); + + return BlendFunc::compare(sa); + } + + /** Return the buffer index as the member identifier.*/ + virtual unsigned int getMember() const { return _index; } + + /** Set the renderbuffer index of the BlendFunci. */ + void setIndex(unsigned int buf) { _index = buf; } + + /** Get the renderbuffer index of the BlendFunci. */ + unsigned int getIndex() const { return _index; } + + virtual void apply(State& state) const; + + protected: + + virtual ~BlendFunci(); + + unsigned int _index; + +}; + +} + +#endif diff --git a/include/osg/ColorMaski b/include/osg/ColorMaski new file mode 100644 index 000000000..548f680e0 --- /dev/null +++ b/include/osg/ColorMaski @@ -0,0 +1,81 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef OSG_COLORMASKI +#define OSG_COLORMASKI 1 + +#include + +namespace osg { + +/** Encapsulates glColorMaski function : the index version of glColorMask for multiple render target. +*/ +class OSG_EXPORT ColorMaski : public ColorMask +{ + public : + + ColorMaski(); + + ColorMaski(unsigned int buf, bool red, bool green, bool blue, bool alpha): + ColorMask(red, green,blue,alpha), + _index(buf) {} + + /** Copy constructor using CopyOp to manage deep vs shallow copy. */ + ColorMaski(const ColorMaski& cm,const CopyOp& copyop=CopyOp::SHALLOW_COPY): + ColorMask(cm,copyop), + _index(cm._index) {} + + META_StateAttribute(osg, ColorMaski, COLORMASK); + + /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */ + virtual int compare(const StateAttribute& sa) const + { + // Check for equal types, then create the rhs variable + // used by the COMPARE_StateAttribute_Parameter macros below. + COMPARE_StateAttribute_Types(ColorMaski,sa) + + COMPARE_StateAttribute_Parameter(_index); + + return ColorMask::compare(sa); + } + + /** Return the buffer index as the member identifier.*/ + virtual unsigned int getMember() const { return _index; } + + /** Set the renderbuffer index of the ColorMaski. */ + void setIndex(unsigned int buf) { _index = buf; } + + /** Get the renderbuffer index of the ColorMaski. */ + unsigned int getIndex() const { return _index; } + + virtual void apply(State& state) const; + + /** Encapsulates queries of extension availability, obtains extension function pointers. */ + struct OSG_EXPORT Extensions : public osg::Referenced + { + Extensions(unsigned int contextID); + + void (GL_APIENTRY * glColorMaski)(GLuint buf, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); + }; + + protected: + + virtual ~ColorMaski(); + + unsigned int _index; + +}; + +} + +#endif diff --git a/src/osg/BlendEquation.cpp b/src/osg/BlendEquation.cpp index e328cd672..7d83f781b 100644 --- a/src/osg/BlendEquation.cpp +++ b/src/osg/BlendEquation.cpp @@ -40,6 +40,9 @@ BlendEquation::Extensions::Extensions(unsigned int contextID) setGLExtensionFuncPtr(glBlendEquation, "glBlendEquation", "glBlendEquationEXT"); setGLExtensionFuncPtr(glBlendEquationSeparate, "glBlendEquationSeparate", "glBlendEquationSeparateEXT"); + + setGLExtensionFuncPtr(glBlendEquationi, "glBlendEquationi", "glBlendEquationiARB"); + setGLExtensionFuncPtr(glBlendEquationSeparatei, "glBlendEquationSeparatei", "glBlendEquationSeparateiARB"); } BlendEquation::BlendEquation(): diff --git a/src/osg/BlendEquationi.cpp b/src/osg/BlendEquationi.cpp new file mode 100644 index 000000000..b4ae40dd8 --- /dev/null +++ b/src/osg/BlendEquationi.cpp @@ -0,0 +1,55 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ +#include +#include +#include + +using namespace osg; + +BlendEquationi::BlendEquationi(): + _index(0) +{ +} + + +BlendEquationi::~BlendEquationi() +{ +} + +void BlendEquationi::apply(State& state) const +{ + const Extensions* extensions = state.get(); + if (_equationRGB == _equationAlpha) + { + if (extensions->glBlendEquationi) + { + extensions->glBlendEquationi(static_cast(_index), static_cast(_equationRGB)); + } + else + { + OSG_WARN<<"Warning: BlendEquationi::apply(..) not supported by OpenGL driver." << std::endl; + } + } + else + { + if (extensions->glBlendEquationSeparatei) + { + extensions->glBlendEquationSeparatei(static_cast(_index), static_cast(_equationRGB), static_cast(_equationAlpha)); + } + else + { + OSG_WARN<<"Warning: BlendEquation::apply(..) failed, glBlendEquationSeparatei not supported by OpenGL driver." << std::endl; + } + } +} + diff --git a/src/osg/BlendFunc.cpp b/src/osg/BlendFunc.cpp index 32d450b84..99169ff9b 100644 --- a/src/osg/BlendFunc.cpp +++ b/src/osg/BlendFunc.cpp @@ -25,6 +25,9 @@ BlendFunc::Extensions::Extensions(unsigned int contextID) strncmp((const char*)glGetString(GL_VERSION), "1.4", 3) >= 0; setGLExtensionFuncPtr(glBlendFuncSeparate, "glBlendFuncSeparate", "glBlendFuncSeparateEXT"); + + setGLExtensionFuncPtr(glBlendFunci, "glBlendFunci", "glBlendFunciARB"); + setGLExtensionFuncPtr(glBlendFuncSeparatei, "glBlendFuncSeparatei", "glBlendFuncSeparateiARB"); } BlendFunc::BlendFunc(): diff --git a/src/osg/BlendFunci.cpp b/src/osg/BlendFunci.cpp new file mode 100644 index 000000000..418c04507 --- /dev/null +++ b/src/osg/BlendFunci.cpp @@ -0,0 +1,56 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ +#include +#include +#include + +using namespace osg; + +BlendFunci::BlendFunci(): + _index(0) +{ +} + + +BlendFunci::~BlendFunci() +{ +} + +void BlendFunci::apply(State& state) const +{ + const Extensions* extensions = state.get(); + if (_source_factor != _source_factor_alpha || + _destination_factor != _destination_factor_alpha) + { + if (extensions->glBlendFuncSeparatei) + { + extensions->glBlendFuncSeparatei(static_cast(_index), _source_factor, _destination_factor, _source_factor_alpha, _destination_factor_alpha); + } + else + { + OSG_WARN<<"Warning: BlendFunc::apply(..) failed, BlendFuncSeparatei is not support by OpenGL driver."<glBlendFunci) + { + extensions->glBlendFunci(static_cast(_index), _source_factor, _destination_factor); + } + else + { + OSG_WARN<<"Warning: BlendFunc::apply(..) failed, BlendFunci is not support by OpenGL driver."< +#include +#include + +using namespace osg; + +// Set up extensions +ColorMaski::Extensions::Extensions(unsigned int contextID) +{ + setGLExtensionFuncPtr(glColorMaski, "glColorMaski", "glColorMaskiARB"); +} + + +ColorMaski::ColorMaski(): + _index(0) +{ +} + +ColorMaski::~ColorMaski() +{ +} + +void ColorMaski::apply(State& state) const +{ + const Extensions* extensions = state.get(); + if (extensions->glColorMaski) + { + extensions->glColorMaski((GLboolean)_index, (GLboolean)_red,(GLboolean)_green,(GLboolean)_blue,(GLboolean)_alpha); + } + else + { + OSG_WARN<<"Warning: ColorMaski::apply(..) failed, glColorMaski is not support by OpenGL driver."< +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( BlendEquationi, + new osg::BlendEquationi, + osg::BlendEquationi, + "osg::Object osg::StateAttribute osg::BlendEquation osg::BlendEquationi" ) +{ + ADD_UINT_SERIALIZER( Index, 0 ); +} diff --git a/src/osgWrappers/serializers/osg/BlendFunci.cpp b/src/osgWrappers/serializers/osg/BlendFunci.cpp new file mode 100644 index 000000000..d70d0e826 --- /dev/null +++ b/src/osgWrappers/serializers/osg/BlendFunci.cpp @@ -0,0 +1,12 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( BlendFunci, + new osg::BlendFunci, + osg::BlendFunci, + "osg::Object osg::StateAttribute osg::BlendFunc osg::BlendFunci" ) +{ + ADD_UINT_SERIALIZER( Index, 0 ); +} diff --git a/src/osgWrappers/serializers/osg/ColorMaski.cpp b/src/osgWrappers/serializers/osg/ColorMaski.cpp new file mode 100644 index 000000000..c673562c1 --- /dev/null +++ b/src/osgWrappers/serializers/osg/ColorMaski.cpp @@ -0,0 +1,12 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( ColorMaski, + new osg::ColorMaski, + osg::ColorMaski, + "osg::Object osg::StateAttribute osg::ColorMask osg::ColorMaski" ) +{ + ADD_UINT_SERIALIZER( Index, 0 ); +}