openscenegraph
ScissorIndexed
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2016 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_ScissorIndexed
15#define OSG_ScissorIndexed 1
16
17#include <osg/Depth>
18
19namespace osg {
20
21/** Encapsulates glScissorIndexed function : the index version of glDepth
22*/
23class OSG_EXPORT ScissorIndexed : public osg::StateAttribute
24{
25 public :
26
27 ScissorIndexed();
28
29 ScissorIndexed(unsigned int index, float x, float y, float width, float height):
30 _index(index),
31 _x(x),
32 _y(y),
33 _width(width),
34 _height(height) {}
35
36 /** Copy constructor using CopyOp to manage deep vs shallow copy. */
37 ScissorIndexed(const ScissorIndexed& dp,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
38 StateAttribute(dp,copyop),
39 _index(dp._index),
40 _x(dp._x),
41 _y(dp._y),
42 _width(dp._width),
43 _height(dp._height) {}
44
45 META_StateAttribute(osg, ScissorIndexed, SCISSORINDEXED);
46
47 /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
48 virtual int compare(const StateAttribute& sa) const
49 {
50 // Check for equal types, then create the rhs variable
51 // used by the COMPARE_StateAttribute_Parameter macros below.
52 COMPARE_StateAttribute_Types(ScissorIndexed,sa)
53
54 COMPARE_StateAttribute_Parameter(_index);
55 COMPARE_StateAttribute_Parameter(_x)
56 COMPARE_StateAttribute_Parameter(_y)
57 COMPARE_StateAttribute_Parameter(_width)
58 COMPARE_StateAttribute_Parameter(_height)
59
60 return 0;
61 }
62
63 /** Return the buffer index as the member identifier.*/
64 virtual unsigned int getMember() const { return _index; }
65
66 /** Set the index of the ScissorIndexed. */
67 void setIndex(unsigned int index);
68
69 /** Get the index of the ScissorIndexed. */
70 unsigned int getIndex() const { return _index; }
71
72 inline void setX(float x) { _x=x; }
73 inline float getX() const { return _x; }
74
75 inline void setY(float y) { _y=y; }
76 inline float getY() const { return _y; }
77
78 inline void setWidth(float w) { _width=w; }
79 inline float getWidth() const { return _width; }
80
81 inline void setHeight(float height) { _height=height; }
82 inline float getHeight() const { return _height; }
83
84 virtual void apply(State& state) const;
85
86 protected:
87
88 virtual ~ScissorIndexed();
89
90 unsigned int _index;
91 float _x;
92 float _y;
93 float _width;
94 float _height;
95
96};
97
98}
99
100#endif