Added PolygonStipple class from Mike, with mods from Robert to make data
management local.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <osg/Vec3>
|
||||
#include <osg/MatrixTransform>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/PolygonStipple>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
@@ -489,6 +490,11 @@ osg::Node* createScene()
|
||||
polyGeom->addPrimitive(new osg::DrawArrays(osg::Primitive::TRIANGLE_STRIP,6,6));
|
||||
polyGeom->addPrimitive(new osg::DrawArrays(osg::Primitive::TRIANGLE_FAN,12,5));
|
||||
|
||||
// polygon stipple
|
||||
osg::StateSet* stateSet = new osg::StateSet();
|
||||
polyGeom->setStateSet(stateSet);
|
||||
osg::PolygonStipple* polygonStipple = new osg::PolygonStipple;
|
||||
stateSet->setAttributeAndModes(polygonStipple,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
|
||||
|
||||
printTriangles("Triangles/Strip/Fan",*polyGeom);
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ CXXFILES =\
|
||||
Point.cpp\
|
||||
PolygonMode.cpp\
|
||||
PolygonOffset.cpp\
|
||||
PolygonStipple.cpp\
|
||||
PositionAttitudeTransform.cpp\
|
||||
Primitive.cpp\
|
||||
Projection.cpp\
|
||||
|
||||
69
src/osg/PolygonStipple.cpp
Normal file
69
src/osg/PolygonStipple.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
#include <osg/GL>
|
||||
#include <osg/PolygonStipple>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
static GLubyte defaultPolygonStippleMask[] =
|
||||
{
|
||||
0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
|
||||
0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
|
||||
0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
|
||||
0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
|
||||
0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
|
||||
0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
|
||||
0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
|
||||
0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
|
||||
0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
|
||||
0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
|
||||
0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
|
||||
0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
|
||||
0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
|
||||
0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
|
||||
0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
|
||||
0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99
|
||||
};
|
||||
|
||||
PolygonStipple::PolygonStipple()
|
||||
{
|
||||
setMask(defaultPolygonStippleMask);
|
||||
}
|
||||
|
||||
PolygonStipple::PolygonStipple(const PolygonStipple& ps,const CopyOp& copyop):
|
||||
StateAttribute(ps,copyop)
|
||||
{
|
||||
setMask(ps.getMask());
|
||||
}
|
||||
|
||||
PolygonStipple::~PolygonStipple()
|
||||
{
|
||||
}
|
||||
|
||||
int PolygonStipple::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(PolygonStipple,sa)
|
||||
|
||||
// compare each parameter in turn against the rhs.
|
||||
for(unsigned int i=0;i<128;++i)
|
||||
{
|
||||
if (_mask[i]<rhs._mask[i]) return -1;
|
||||
else if (_mask[i]>rhs._mask[i]) return 1;
|
||||
}
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
void PolygonStipple::setMask(const GLubyte* givenMask)
|
||||
{
|
||||
std::copy(givenMask,givenMask+128,_mask);
|
||||
}
|
||||
|
||||
void PolygonStipple::apply(State&) const
|
||||
{
|
||||
glPolygonStipple(_mask);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user