1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 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>
22class OSG_EXPORT Capability : public osg::StateAttribute
28 Capability(GLenum capability):
29 _capability(capability) {}
31 /** Copy constructor using CopyOp to manage deep vs shallow copy. */
32 Capability(const Capability& cap,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
33 StateAttribute(cap, copyop),
34 _capability(cap._capability) {}
36 META_Object(osg, Capability);
38 /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
39 virtual int compare(const StateAttribute& sa) const
41 // Check for equal types, then create the rhs variable
42 // used by the COMPARE_StateAttribute_Parameter macros below.
43 COMPARE_StateAttribute_Types(Capability,sa)
45 COMPARE_StateAttribute_Parameter(_capability);
50 /** Return the Type identifier of the attribute's class type.*/
51 virtual Type getType() const { return static_cast<Type>(CAPABILITY+_capability); }
53 void setCapability(GLenum capability) { _capability = capability; }
55 GLenum getCapability() const { return _capability; }
59 virtual ~Capability();
65/** Encapsulates glEnablei/glDisablei
67class OSG_EXPORT Capabilityi : public osg::Capability
73 Capabilityi(GLenum capability, unsigned int buf):
74 Capability(capability),
77 /** Copy constructor using CopyOp to manage deep vs shallow copy. */
78 Capabilityi(const Capabilityi& cap,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
79 Capability(cap,copyop),
82 META_Object(osg, Capabilityi);
84 /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
85 virtual int compare(const StateAttribute& sa) const
87 // Check for equal types, then create the rhs variable
88 // used by the COMPARE_StateAttribute_Parameter macros below.
89 COMPARE_StateAttribute_Types(Capabilityi,sa)
91 COMPARE_StateAttribute_Parameter(_index);
92 COMPARE_StateAttribute_Parameter(_capability);
97 /** Return the member identifier within the attribute's class type. Used for light number/clip plane number etc.*/
98 virtual unsigned int getMember() const { return _index; }
100 /** Set the renderbuffer index of the Enablei. */
101 void setIndex(unsigned int buf) { _index = buf; }
103 /** Get the renderbuffer index of the Enablei. */
104 unsigned int getIndex() const { return _index; }
108 virtual ~Capabilityi();
114class OSG_EXPORT Enablei : public Capabilityi
120 Enablei(unsigned int buf, GLenum capability):
121 Capabilityi(buf, capability) {}
123 /** Copy constructor using CopyOp to manage deep vs shallow copy. */
124 Enablei(const Enablei& ei,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
125 Capabilityi(ei,copyop) {}
127 META_Object(osg, Enablei);
129 virtual void apply(State&) const;
133 virtual ~Enablei() {}
137class OSG_EXPORT Disablei : public Capabilityi
143 Disablei(unsigned int buf, GLenum capability):
144 Capabilityi(buf, capability) {}
146 /** Copy constructor using CopyOp to manage deep vs shallow copy. */
147 Disablei(const Disablei& ei,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
148 Capabilityi(ei,copyop) {}
150 META_Object(osg, Disablei);
152 virtual void apply(State&) const;
156 virtual ~Disablei() {}