Added support for glLineWidth via an osg::LineWidth StateAttribute.

This commit is contained in:
Robert Osfield
2001-12-20 20:48:46 +00:00
parent 8aa72d85cf
commit 9365f0e3b1
8 changed files with 149 additions and 3 deletions

27
src/osg/LineWidth.cpp Normal file
View 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);
}

View File

@@ -28,6 +28,7 @@ C++FILES = \
Light.cpp\
LightSource.cpp\
LineSegment.cpp\
LineWidth.cpp\
LOD.cpp\
Material.cpp\
Matrix.cpp\

View 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;
}

View File

@@ -20,6 +20,7 @@ C++FILES = \
Impostor.cpp\
Light.cpp\
LightSource.cpp\
LineWidth.cpp\
LOD.cpp\
Material.cpp\
Matrix.cpp\