openscenegraph
Hint
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_HINT
15#define OSG_HINT 1
16
17#include <osg/StateAttribute>
18
19namespace osg
20{
21
22class OSG_EXPORT Hint : public StateAttribute
23{
24public:
25
26 Hint():
27 _target(GL_NONE),
28 _mode(GL_DONT_CARE) {}
29
30 Hint(GLenum target, GLenum mode):
31 _target(target),
32 _mode(mode) {}
33
34 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
35 Hint(const Hint& hint,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
36 StateAttribute(hint,copyop),
37 _target(hint._target),
38 _mode(hint._mode) {}
39
40 virtual osg::Object* cloneType() const { return new Hint( _target, GL_DONT_CARE ); }
41 virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new Hint(*this,copyop); }
42 virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Hint *>(obj)!=NULL; }
43 virtual const char* libraryName() const { return "osg"; }
44 virtual const char* className() const { return "Hint"; }
45 virtual Type getType() const { return HINT; }
46
47 virtual int compare(const StateAttribute& sa) const
48 {
49 // check the types are equal and then create the rhs variable
50 // used by the COMPARE_StateAttribute_Parameter macros below.
51 COMPARE_StateAttribute_Types(Hint,sa)
52
53 // compare each parameter in turn against the rhs.
54 COMPARE_StateAttribute_Parameter(_target)
55 COMPARE_StateAttribute_Parameter(_mode)
56
57 return 0;
58 }
59
60 /** Return the member identifier within the attribute's class type. Used for light number/clip plane number etc.*/
61 virtual unsigned int getMember() const { return static_cast<unsigned int>(_target); }
62
63 void setTarget(GLenum target);
64 inline GLenum getTarget() const { return _target; }
65
66 inline void setMode(GLenum mode) { _mode = mode; }
67 inline GLenum getMode() const { return _mode; }
68
69 virtual void apply(State& state) const;
70
71protected:
72
73
74 GLenum _target;
75 GLenum _mode;
76};
77
78
79}
80
81#endif