openscenegraph
LineStipple
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2004 Robert Osfield
2 *
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.
7 *
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.
12*/
13
14#ifndef OSG_LINESTIPPLE
15#define OSG_LINESTIPPLE 1
16
17#include <osg/StateAttribute>
18
19#ifndef GL_LINE_STIPPLE
20 #define GL_LINE_STIPPLE 0x0B24
21#endif
22
23namespace osg {
24
25class OSG_EXPORT LineStipple : public StateAttribute
26{
27 public :
28
29 LineStipple();
30
31 LineStipple(GLint factor, GLushort pattern):
32 _factor(factor),
33 _pattern(pattern) {}
34
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),
38 _factor(lw._factor),
39 _pattern(lw._pattern) {}
40
41 META_StateAttribute(osg, LineStipple, LINESTIPPLE);
42
43 /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
44 virtual int compare(const StateAttribute& sa) const
45 {
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)
49
50 // compare each parameter in turn against the rhs.
51 COMPARE_StateAttribute_Parameter(_factor)
52 COMPARE_StateAttribute_Parameter(_pattern)
53
54 return 0; // passed all the above comparison macros, must be equal.
55 }
56
57 virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
58 {
59 usage.usesMode(GL_LINE_STIPPLE);
60 return true;
61 }
62
63 void setFactor(GLint factor);
64 inline GLint getFactor() const { return _factor; }
65
66 void setPattern(GLushort pattern);
67 inline GLushort getPattern() const { return _pattern; }
68
69 virtual void apply(State& state) const;
70
71
72 protected :
73
74 virtual ~LineStipple();
75
76 GLint _factor;
77 GLushort _pattern;
78
79};
80
81}
82
83#endif