1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2004 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
14#ifndef OSG_LINESTIPPLE
15#define OSG_LINESTIPPLE 1
17#include <osg/StateAttribute>
19#ifndef GL_LINE_STIPPLE
20 #define GL_LINE_STIPPLE 0x0B24
25class OSG_EXPORT LineStipple : public StateAttribute
31 LineStipple(GLint factor, GLushort pattern):
35 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
36 LineStipple(const LineStipple& lw,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
37 StateAttribute(lw,copyop),
39 _pattern(lw._pattern) {}
41 META_StateAttribute(osg, LineStipple, LINESTIPPLE);
43 /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
44 virtual int compare(const StateAttribute& sa) const
46 // check if the types are equal and then create the rhs variable.
47 // used by the COMPARE_StateAttribute_Parameter macros below.
48 COMPARE_StateAttribute_Types(LineStipple,sa)
50 // compare each parameter in turn against the rhs.
51 COMPARE_StateAttribute_Parameter(_factor)
52 COMPARE_StateAttribute_Parameter(_pattern)
54 return 0; // passed all the above comparison macros, must be equal.
57 virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
59 usage.usesMode(GL_LINE_STIPPLE);
63 void setFactor(GLint factor);
64 inline GLint getFactor() const { return _factor; }
66 void setPattern(GLushort pattern);
67 inline GLushort getPattern() const { return _pattern; }
69 virtual void apply(State& state) const;
74 virtual ~LineStipple();