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.
18#include <osg/StateAttribute>
22/** Class to globally enable/disable OpenGL's polygon culling mode.
24class OSG_EXPORT CullFace : public StateAttribute
31 FRONT_AND_BACK = GL_FRONT_AND_BACK
34 CullFace(Mode mode=BACK):
37 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
38 CullFace(const CullFace& cf,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
39 StateAttribute(cf,copyop),
42 META_StateAttribute(osg, CullFace, CULLFACE);
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(CullFace,sa)
51 // compare each parameter in turn against the rhs.
52 COMPARE_StateAttribute_Parameter(_mode)
54 return 0; // passed all the above comparison macros, must be equal.
57 virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
59 usage.usesMode(GL_CULL_FACE);
63 inline void setMode(Mode mode) { _mode = mode; }
65 inline Mode getMode() const { return _mode; }
67 virtual void apply(State& state) const;