Added support for glLineStipple via osg::LineStipple state attribute.
This commit is contained in:
60
src/osgPlugins/osg/LineStipple.cpp
Normal file
60
src/osgPlugins/osg/LineStipple.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include <osg/LineStipple>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgDB;
|
||||
|
||||
// forward declare functions to use later.
|
||||
bool LineStipple_readLocalData(Object& obj, Input& fr);
|
||||
bool LineStipple_writeLocalData(const Object& obj, Output& fw);
|
||||
|
||||
|
||||
// register the read and write functions with the osgDB::Registry.
|
||||
RegisterDotOsgWrapperProxy g_LineStippleProxy
|
||||
(
|
||||
new osg::LineStipple,
|
||||
"LineStipple",
|
||||
"Object StateAttribute LineStipple",
|
||||
&LineStipple_readLocalData,
|
||||
&LineStipple_writeLocalData
|
||||
);
|
||||
|
||||
|
||||
bool LineStipple_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
|
||||
LineStipple& linestipple = static_cast<LineStipple&>(obj);
|
||||
|
||||
int ref = linestipple.getFactor();
|
||||
if (fr[0].matchWord("factor") && fr[1].getInt(ref))
|
||||
{
|
||||
linestipple.setFactor(ref);
|
||||
fr+=2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
osg::uint mask = linestipple.getPattern();
|
||||
if (fr[0].matchWord("functionMask") && fr[1].getUInt(mask))
|
||||
{
|
||||
linestipple.setPattern(mask);
|
||||
fr+=2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool LineStipple_writeLocalData(const Object& obj,Output& fw)
|
||||
{
|
||||
const LineStipple& linestipple = static_cast<const LineStipple&>(obj);
|
||||
|
||||
fw.indent() << "factor " << linestipple.getFactor() << std::endl;
|
||||
fw.indent() << "pattern 0x" << std::hex << linestipple.getPattern() << std::dec << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ C++FILES = \
|
||||
Impostor.cpp\
|
||||
Light.cpp\
|
||||
LightSource.cpp\
|
||||
LineStipple.cpp\
|
||||
LineWidth.cpp\
|
||||
LOD.cpp\
|
||||
Material.cpp\
|
||||
|
||||
@@ -65,6 +65,7 @@ void initGLNames()
|
||||
ADD_NAME("GL_FOG",GL_FOG)
|
||||
ADD_NAME("GL_LIGHTING",GL_LIGHTING)
|
||||
ADD_NAME("GL_POINT_SMOOTH",GL_POINT_SMOOTH)
|
||||
ADD_NAME("GL_LINE_STIPPLE",GL_LINE_STIPPLE)
|
||||
ADD_NAME("GL_POLYGON_OFFSET_FILL",GL_POLYGON_OFFSET_FILL)
|
||||
ADD_NAME("GL_POLYGON_OFFSET_LINE",GL_POLYGON_OFFSET_LINE)
|
||||
ADD_NAME("GL_POLYGON_OFFSET_POINT",GL_POLYGON_OFFSET_POINT)
|
||||
@@ -304,7 +305,6 @@ bool StateSet_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
if (StateSet_matchModeStr(fr[1].getStr(),value))
|
||||
{
|
||||
|
||||
int mode;
|
||||
fr[0].getInt(mode);
|
||||
stateset.setMode((StateAttribute::GLMode)mode,value);
|
||||
|
||||
Reference in New Issue
Block a user