openscenegraph
ClipControl
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_CLIPCONTROL
15#define OSG_CLIPCONTROL 1
16
17#include <osg/StateAttribute>
18
19#ifndef GL_VERSION_4_5
20 #define GL_NEGATIVE_ONE_TO_ONE 0x935E
21 #define GL_ZERO_TO_ONE 0x935F
22#endif
23
24namespace osg {
25
26/** Encapsulate OpenGL glClipControl functions.
27*/
28class OSG_EXPORT ClipControl : public StateAttribute
29{
30 public :
31
32 enum Origin
33 {
34 LOWER_LEFT = GL_LOWER_LEFT,
35 UPPER_LEFT = GL_UPPER_LEFT
36 };
37
38 enum DepthMode
39 {
40 NEGATIVE_ONE_TO_ONE = GL_NEGATIVE_ONE_TO_ONE,
41 ZERO_TO_ONE = GL_ZERO_TO_ONE
42 };
43
44
45 ClipControl(Origin origin=LOWER_LEFT, DepthMode depthMode=NEGATIVE_ONE_TO_ONE);
46
47 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
48 ClipControl(const ClipControl& clipControl,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
49
50
51 META_StateAttribute(osg, ClipControl, CLIPCONTROL);
52
53 /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
54 virtual int compare(const StateAttribute& sa) const
55 {
56 // check the types are equal and then create the rhs variable
57 // used by the COMPARE_StateAttribute_Parameter macros below.
58 COMPARE_StateAttribute_Types(ClipControl,sa)
59
60 // compare each parameter in turn against the rhs.
61 COMPARE_StateAttribute_Parameter(_origin)
62 COMPARE_StateAttribute_Parameter(_depthMode)
63
64 return 0; // passed all the above comparison macros, must be equal.
65 }
66
67 void setOrigin(Origin origin) { _origin = origin; }
68 Origin getOrigin() const { return _origin; }
69
70 void setDepthMode(DepthMode depthMode) { _depthMode = depthMode; }
71 DepthMode getDepthMode() const { return _depthMode; }
72
73 virtual void apply(State& state) const;
74
75 protected:
76
77 virtual ~ClipControl();
78
79 Origin _origin;
80 DepthMode _depthMode;
81};
82
83}
84
85#endif