Added support for glLineWidth via an osg::LineWidth StateAttribute.
This commit is contained in:
parent
8aa72d85cf
commit
9365f0e3b1
@ -197,6 +197,10 @@ SOURCE=..\..\src\osg\LineSegment.cpp
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\src\osg\LineWidth.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\src\osg\LOD.cpp
|
SOURCE=..\..\src\osg\LOD.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
@ -425,6 +429,10 @@ SOURCE=..\..\Include\Osg\LineSegment
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\Include\Osg\LineWidth
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\Include\Osg\Lod
|
SOURCE=..\..\Include\Osg\Lod
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@ -166,6 +166,10 @@ SOURCE=..\..\..\src\osgPlugins\osg\LightSource.cpp
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\..\src\osgPlugins\osg\LineWidth.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\..\src\osgPlugins\osg\LOD.cpp
|
SOURCE=..\..\..\src\osgPlugins\osg\LOD.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
50
include/osg/LineWidth
Normal file
50
include/osg/LineWidth
Normal file
@ -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 <osg/StateAttribute>
|
||||||
|
#include <osg/StateSet>
|
||||||
|
|
||||||
|
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
|
@ -120,9 +120,10 @@ class SG_EXPORT StateAttribute : public Object
|
|||||||
LIGHT_5 =LIGHT+1,
|
LIGHT_5 =LIGHT+1,
|
||||||
LIGHT_6 =LIGHT+1,
|
LIGHT_6 =LIGHT+1,
|
||||||
LIGHT_7 =LIGHT+1,
|
LIGHT_7 =LIGHT+1,
|
||||||
POINT =LIGHT_7+1,
|
|
||||||
|
POINT =LIGHT_7+1,
|
||||||
POLYGONMODE =POINT+1,
|
LINEWIDTH =POINT+1,
|
||||||
|
POLYGONMODE =LINEWIDTH+1,
|
||||||
POLYGONOFFSET =POLYGONMODE+1,
|
POLYGONOFFSET =POLYGONMODE+1,
|
||||||
TEXENV =POLYGONOFFSET+1,
|
TEXENV =POLYGONOFFSET+1,
|
||||||
TEXGEN =TEXENV+1,
|
TEXGEN =TEXENV+1,
|
||||||
|
27
src/osg/LineWidth.cpp
Normal file
27
src/osg/LineWidth.cpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#include <osg/GL>
|
||||||
|
#include <osg/LineWidth>
|
||||||
|
#include <osg/Notify>
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
@ -28,6 +28,7 @@ C++FILES = \
|
|||||||
Light.cpp\
|
Light.cpp\
|
||||||
LightSource.cpp\
|
LightSource.cpp\
|
||||||
LineSegment.cpp\
|
LineSegment.cpp\
|
||||||
|
LineWidth.cpp\
|
||||||
LOD.cpp\
|
LOD.cpp\
|
||||||
Material.cpp\
|
Material.cpp\
|
||||||
Matrix.cpp\
|
Matrix.cpp\
|
||||||
|
54
src/osgPlugins/osg/LineWidth.cpp
Normal file
54
src/osgPlugins/osg/LineWidth.cpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#if defined(_MSC_VER)
|
||||||
|
#pragma warning( disable : 4786 )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <osg/LineWidth>
|
||||||
|
|
||||||
|
#include <osgDB/Registry>
|
||||||
|
#include <osgDB/Input>
|
||||||
|
#include <osgDB/Output>
|
||||||
|
|
||||||
|
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<LineWidth&>(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<const LineWidth&>(obj);
|
||||||
|
|
||||||
|
fw.indent() << "width " << lineWidth.getWidth() << std::endl;
|
||||||
|
return true;
|
||||||
|
}
|
@ -20,6 +20,7 @@ C++FILES = \
|
|||||||
Impostor.cpp\
|
Impostor.cpp\
|
||||||
Light.cpp\
|
Light.cpp\
|
||||||
LightSource.cpp\
|
LightSource.cpp\
|
||||||
|
LineWidth.cpp\
|
||||||
LOD.cpp\
|
LOD.cpp\
|
||||||
Material.cpp\
|
Material.cpp\
|
||||||
Matrix.cpp\
|
Matrix.cpp\
|
||||||
|
Loading…
Reference in New Issue
Block a user