diff --git a/VisualStudio/osg/osg.dsp b/VisualStudio/osg/osg.dsp index c071b2318..a80e2e9f1 100755 --- a/VisualStudio/osg/osg.dsp +++ b/VisualStudio/osg/osg.dsp @@ -197,6 +197,10 @@ SOURCE=..\..\src\osg\LineSegment.cpp # End Source File # Begin Source File +SOURCE=..\..\src\osg\LineWidth.cpp +# End Source File +# Begin Source File + SOURCE=..\..\src\osg\LOD.cpp # End Source File # Begin Source File @@ -425,6 +429,10 @@ SOURCE=..\..\Include\Osg\LineSegment # End Source File # Begin Source File +SOURCE=..\..\Include\Osg\LineWidth +# End Source File +# Begin Source File + SOURCE=..\..\Include\Osg\Lod # End Source File # Begin Source File diff --git a/VisualStudio/osgPlugins/osg/dot_osg.dsp b/VisualStudio/osgPlugins/osg/dot_osg.dsp index 3a85b7ce0..2d0ee3d4e 100755 --- a/VisualStudio/osgPlugins/osg/dot_osg.dsp +++ b/VisualStudio/osgPlugins/osg/dot_osg.dsp @@ -166,6 +166,10 @@ SOURCE=..\..\..\src\osgPlugins\osg\LightSource.cpp # End Source File # Begin Source File +SOURCE=..\..\..\src\osgPlugins\osg\LineWidth.cpp +# End Source File +# Begin Source File + SOURCE=..\..\..\src\osgPlugins\osg\LOD.cpp # End Source File # Begin Source File diff --git a/include/osg/LineWidth b/include/osg/LineWidth new file mode 100644 index 000000000..c992c52e3 --- /dev/null +++ b/include/osg/LineWidth @@ -0,0 +1,50 @@ +//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_LineWidth +#define OSG_LineWidth 1 + +#include +#include + +namespace osg { + +/** LineWidth - encapsulates the OpenGL glLineWidth for setting the width of lines in pixels.*/ +class SG_EXPORT LineWidth : public StateAttribute +{ + public : + + LineWidth(); + + META_StateAttribute(LineWidth, LINEWIDTH); + + /** 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(LineWidth,sa) + + // compare each paramter in turn against the rhs. + COMPARE_StateAttribute_Parameter(_width) + + return 0; // passed all the above comparison macro's, must be equal. + } + + void setWidth(const float width); + inline const float getWidth() const { return _width; } + + virtual void apply(State& state) const; + + protected : + + virtual ~LineWidth(); + + float _width; + +}; + +}; + +#endif diff --git a/include/osg/StateAttribute b/include/osg/StateAttribute index df26f6b56..77358663b 100644 --- a/include/osg/StateAttribute +++ b/include/osg/StateAttribute @@ -120,9 +120,10 @@ class SG_EXPORT StateAttribute : public Object LIGHT_5 =LIGHT+1, LIGHT_6 =LIGHT+1, LIGHT_7 =LIGHT+1, - POINT =LIGHT_7+1, - - POLYGONMODE =POINT+1, + + POINT =LIGHT_7+1, + LINEWIDTH =POINT+1, + POLYGONMODE =LINEWIDTH+1, POLYGONOFFSET =POLYGONMODE+1, TEXENV =POLYGONOFFSET+1, TEXGEN =TEXENV+1, diff --git a/src/osg/LineWidth.cpp b/src/osg/LineWidth.cpp new file mode 100644 index 000000000..756c33602 --- /dev/null +++ b/src/osg/LineWidth.cpp @@ -0,0 +1,27 @@ +#include +#include +#include + +using namespace osg; + + +LineWidth::LineWidth() +{ + _width = 1.0f; +} + + +LineWidth::~LineWidth() +{ +} + +void LineWidth::setWidth( const float width ) +{ + _width = width; +} + +void LineWidth::apply(State&) const +{ + glLineWidth(_width); +} + diff --git a/src/osg/Makefile b/src/osg/Makefile index 917466372..941b335db 100644 --- a/src/osg/Makefile +++ b/src/osg/Makefile @@ -28,6 +28,7 @@ C++FILES = \ Light.cpp\ LightSource.cpp\ LineSegment.cpp\ + LineWidth.cpp\ LOD.cpp\ Material.cpp\ Matrix.cpp\ diff --git a/src/osgPlugins/osg/LineWidth.cpp b/src/osgPlugins/osg/LineWidth.cpp new file mode 100644 index 000000000..fabf69ff0 --- /dev/null +++ b/src/osgPlugins/osg/LineWidth.cpp @@ -0,0 +1,54 @@ +#if defined(_MSC_VER) + #pragma warning( disable : 4786 ) +#endif + +#include + +#include +#include +#include + +using namespace osg; +using namespace osgDB; + +// forward declare functions to use later. +bool LineWidth_readLocalData(Object& obj, Input& fr); +bool LineWidth_writeLocalData(const Object& obj, Output& fw); + +// register the read and write functions with the osgDB::Registry. +RegisterDotOsgWrapperProxy g_LineWidthProxy +( + new osg::LineWidth, + "LineWidth", + "Object StateAttribute LineWidth", + &LineWidth_readLocalData, + &LineWidth_writeLocalData +); + + +bool LineWidth_readLocalData(Object& obj, Input& fr) +{ + bool iteratorAdvanced = false; + + LineWidth& lineWidth = static_cast(obj); + + float data; + if (fr[0].matchWord("width") && fr[1].getFloat(data)) + { + + lineWidth.setWidth(data); + fr+=2; + iteratorAdvanced = true; + } + + return iteratorAdvanced; +} + + +bool LineWidth_writeLocalData(const Object& obj, Output& fw) +{ + const LineWidth& lineWidth = static_cast(obj); + + fw.indent() << "width " << lineWidth.getWidth() << std::endl; + return true; +} diff --git a/src/osgPlugins/osg/Makefile b/src/osgPlugins/osg/Makefile index 6ec4c8bb3..5c28d15bb 100644 --- a/src/osgPlugins/osg/Makefile +++ b/src/osgPlugins/osg/Makefile @@ -20,6 +20,7 @@ C++FILES = \ Impostor.cpp\ Light.cpp\ LightSource.cpp\ + LineWidth.cpp\ LOD.cpp\ Material.cpp\ Matrix.cpp\