openscenegraph
Capability
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 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_ENABLEI
15#define OSG_ENABLEI 1
16
17#include <osg/GL>
18#include <osg/StateAttribute>
19
20namespace osg {
21
22class OSG_EXPORT Capability : public osg::StateAttribute
23{
24 public :
25
26 Capability();
27
28 Capability(GLenum capability):
29 _capability(capability) {}
30
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) {}
35
36 META_Object(osg, Capability);
37
38 /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
39 virtual int compare(const StateAttribute& sa) const
40 {
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)
44
45 COMPARE_StateAttribute_Parameter(_capability);
46
47 return 0;
48 }
49
50 /** Return the Type identifier of the attribute's class type.*/
51 virtual Type getType() const { return static_cast<Type>(CAPABILITY+_capability); }
52
53 void setCapability(GLenum capability) { _capability = capability; }
54
55 GLenum getCapability() const { return _capability; }
56
57 protected:
58
59 virtual ~Capability();
60
61 GLenum _capability;
62
63};
64
65/** Encapsulates glEnablei/glDisablei
66*/
67class OSG_EXPORT Capabilityi : public osg::Capability
68{
69 public :
70
71 Capabilityi();
72
73 Capabilityi(GLenum capability, unsigned int buf):
74 Capability(capability),
75 _index(buf) {}
76
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),
80 _index(cap._index) {}
81
82 META_Object(osg, Capabilityi);
83
84 /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
85 virtual int compare(const StateAttribute& sa) const
86 {
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)
90
91 COMPARE_StateAttribute_Parameter(_index);
92 COMPARE_StateAttribute_Parameter(_capability);
93
94 return 0;
95 }
96
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; }
99
100 /** Set the renderbuffer index of the Enablei. */
101 void setIndex(unsigned int buf) { _index = buf; }
102
103 /** Get the renderbuffer index of the Enablei. */
104 unsigned int getIndex() const { return _index; }
105
106protected:
107
108 virtual ~Capabilityi();
109
110 unsigned int _index;
111
112};
113
114class OSG_EXPORT Enablei : public Capabilityi
115{
116 public :
117
118 Enablei() {}
119
120 Enablei(unsigned int buf, GLenum capability):
121 Capabilityi(buf, capability) {}
122
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) {}
126
127 META_Object(osg, Enablei);
128
129 virtual void apply(State&) const;
130
131protected:
132
133 virtual ~Enablei() {}
134};
135
136
137class OSG_EXPORT Disablei : public Capabilityi
138{
139 public :
140
141 Disablei() {}
142
143 Disablei(unsigned int buf, GLenum capability):
144 Capabilityi(buf, capability) {}
145
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) {}
149
150 META_Object(osg, Disablei);
151
152 virtual void apply(State&) const;
153
154 protected:
155
156 virtual ~Disablei() {}
157};
158
159}
160
161#endif