1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 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.
17#include <osg/StateAttribute>
21/** Encapsulate OpenGL glScissor. */
22class OSG_EXPORT Scissor : public StateAttribute
27 Scissor(int x,int y,int width,int height):
34 /** Copy constructor using CopyOp to manage deep vs shallow copy. */
35 Scissor(const Scissor& vp,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
36 StateAttribute(vp,copyop),
40 _height(vp._height) {}
42 META_StateAttribute(osg, Scissor, SCISSOR);
44 /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
45 virtual int compare(const StateAttribute& sa) const
47 // check the types are equal and then create the rhs variable
48 // used by the COMPARE_StateAttribute_Parameter macros below.
49 COMPARE_StateAttribute_Types(Scissor,sa)
51 // compare each parameter in turn against the rhs.
52 COMPARE_StateAttribute_Parameter(_x)
53 COMPARE_StateAttribute_Parameter(_y)
54 COMPARE_StateAttribute_Parameter(_width)
55 COMPARE_StateAttribute_Parameter(_height)
57 return 0; // passed all the above comparison macros, must be equal.
61 virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
63 usage.usesMode(GL_SCISSOR_TEST);
67 inline void setScissor(int x,int y,int width,int height)
75 void getScissor(int& x,int& y,int& width,int& height) const
83 inline int& x() { return _x; }
84 inline int x() const { return _x; }
86 inline int& y() { return _y; }
87 inline int y() const { return _y; }
89 inline int& width() { return _width; }
90 inline int width() const { return _width; }
92 inline int& height() { return _height; }
93 inline int height() const { return _height; }
95 virtual void apply(State& state) const;