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.
14#ifndef OSG_CLIPCONTROL
15#define OSG_CLIPCONTROL 1
17#include <osg/StateAttribute>
20 #define GL_NEGATIVE_ONE_TO_ONE 0x935E
21 #define GL_ZERO_TO_ONE 0x935F
26/** Encapsulate OpenGL glClipControl functions.
28class OSG_EXPORT ClipControl : public StateAttribute
34 LOWER_LEFT = GL_LOWER_LEFT,
35 UPPER_LEFT = GL_UPPER_LEFT
40 NEGATIVE_ONE_TO_ONE = GL_NEGATIVE_ONE_TO_ONE,
41 ZERO_TO_ONE = GL_ZERO_TO_ONE
45 ClipControl(Origin origin=LOWER_LEFT, DepthMode depthMode=NEGATIVE_ONE_TO_ONE);
47 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
48 ClipControl(const ClipControl& clipControl,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
51 META_StateAttribute(osg, ClipControl, CLIPCONTROL);
53 /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
54 virtual int compare(const StateAttribute& sa) const
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)
60 // compare each parameter in turn against the rhs.
61 COMPARE_StateAttribute_Parameter(_origin)
62 COMPARE_StateAttribute_Parameter(_depthMode)
64 return 0; // passed all the above comparison macros, must be equal.
67 void setOrigin(Origin origin) { _origin = origin; }
68 Origin getOrigin() const { return _origin; }
70 void setDepthMode(DepthMode depthMode) { _depthMode = depthMode; }
71 DepthMode getDepthMode() const { return _depthMode; }
73 virtual void apply(State& state) const;
77 virtual ~ClipControl();