OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Scissor.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 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_Scissor
15 #define OSG_Scissor 1
16 
17 #include <osg/StateAttribute>
18 
19 namespace osg {
20 
23 {
24  public :
25  Scissor();
26 
27  Scissor(int x,int y,int width,int height):
28  _x(x),
29  _y(y),
30  _width(width),
31  _height(height) {}
32 
33 
35  Scissor(const Scissor& vp,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
36  StateAttribute(vp,copyop),
37  _x(vp._x),
38  _y(vp._y),
39  _width(vp._width),
40  _height(vp._height) {}
41 
42  META_StateAttribute(osg, Scissor, SCISSOR);
43 
45  virtual int compare(const StateAttribute& sa) const
46  {
47  // check the types are equal and then create the rhs variable
48  // used by the COMPARE_StateAttribute_Parameter macros below.
50 
51  // compare each parameter in turn against the rhs.
56 
57  return 0; // passed all the above comparison macros, must be equal.
58  }
59 
60 
61  virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
62  {
63  usage.usesMode(GL_SCISSOR_TEST);
64  return true;
65  }
66 
67  inline void setScissor(int x,int y,int width,int height)
68  {
69  _x = x;
70  _y = y;
71  _width = width;
72  _height = height;
73  }
74 
75  void getScissor(int& x,int& y,int& width,int& height) const
76  {
77  x = _x;
78  y = _y;
79  width = _width;
80  height = _height;
81  }
82 
83  inline int& x() { return _x; }
84  inline int x() const { return _x; }
85 
86  inline int& y() { return _y; }
87  inline int y() const { return _y; }
88 
89  inline int& width() { return _width; }
90  inline int width() const { return _width; }
91 
92  inline int& height() { return _height; }
93  inline int height() const { return _height; }
94 
95  virtual void apply(State& state) const;
96 
97  protected:
98 
99  virtual ~Scissor();
100 
101  int _x;
102  int _y;
103  int _width;
104  int _height;
105 
106 };
107 
108 }
109 
110 #endif
int & width()
Definition: Scissor.h:89
#define OSG_EXPORT
Definition: Export.h:43
void getScissor(int &x, int &y, int &width, int &height) const
Definition: Scissor.h:75
#define COMPARE_StateAttribute_Types(TYPE, rhs_attribute)
int & x()
Definition: Scissor.h:83
int & y()
Definition: Scissor.h:86
int height() const
Definition: Scissor.h:93
int _height
Definition: Scissor.h:104
virtual void usesMode(GLMode mode)=0
int x() const
Definition: Scissor.h:84
GLint GLenum GLsizei width
Definition: GLU.h:71
#define META_StateAttribute(library, name, type)
GLint GLenum GLsizei GLsizei height
Definition: GLU.h:71
int width() const
Definition: Scissor.h:90
int & height()
Definition: Scissor.h:92
Definition: AlphaFunc.h:19
Scissor(const Scissor &vp, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition: Scissor.h:35
#define COMPARE_StateAttribute_Parameter(parameter)
int y() const
Definition: Scissor.h:87
void setScissor(int x, int y, int width, int height)
Definition: Scissor.h:67
virtual bool getModeUsage(StateAttribute::ModeUsage &usage) const
Definition: Scissor.h:61
virtual int compare(const StateAttribute &sa) const
Definition: Scissor.h:45
Scissor(int x, int y, int width, int height)
Definition: Scissor.h:27
int _width
Definition: Scissor.h:103