Added support for glLineWidth via an osg::LineWidth StateAttribute.
This commit is contained in:
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\
|
||||
LightSource.cpp\
|
||||
LineSegment.cpp\
|
||||
LineWidth.cpp\
|
||||
LOD.cpp\
|
||||
Material.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\
|
||||
Light.cpp\
|
||||
LightSource.cpp\
|
||||
LineWidth.cpp\
|
||||
LOD.cpp\
|
||||
Material.cpp\
|
||||
Matrix.cpp\
|
||||
|
||||
Reference in New Issue
Block a user