OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TexEnv.h
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_TEXENV
15 #define OSG_TEXENV 1
16 
17 #include <osg/GL>
18 #include <osg/StateAttribute>
19 #include <osg/Vec4>
20 
21 #ifndef OSG_GL_FIXED_FUNCTION_AVAILABLE
22  #define GL_MODULATE 0x2100
23  #define GL_ADD 0x0104
24  #define GL_MODULATE 0x2100
25  #define GL_DECAL 0x2101
26 #endif
27 
28 namespace osg {
29 
33 {
34  public :
35 
36  enum Mode {
37  DECAL = GL_DECAL,
38  MODULATE = GL_MODULATE,
39  BLEND = GL_BLEND,
40  REPLACE = GL_REPLACE,
41  ADD = GL_ADD
42  };
43 
44  TexEnv(Mode mode=MODULATE);
45 
47  TexEnv(const TexEnv& texenv,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
48  StateAttribute(texenv,copyop),
49  _mode(texenv._mode),
50  _color(texenv._color) {}
51 
52 
53  META_StateAttribute(osg, TexEnv, TEXENV);
54 
55  virtual bool isTextureAttribute() const { return true; }
56 
58  virtual int compare(const StateAttribute& sa) const
59  {
60  // Check for equal types, then create the rhs variable
61  // used by the COMPARE_StateAttribute_Parameter macros below.
63 
64  // Compare each parameter in turn against the rhs.
67 
68  return 0; // Passed all the above comparison macros, so must be equal.
69  }
70 
71 
72  void setMode( Mode mode ) { _mode = mode; }
73 
74  Mode getMode() const { return _mode; }
75 
76  void setColor( const Vec4& color ) { _color = color; }
77 
78  Vec4& getColor() { return _color; }
79 
80  const Vec4& getColor() const { return _color; }
81 
82 
83  virtual void apply(State& state) const;
84 
85  protected :
86 
87  virtual ~TexEnv( void );
88 
91 };
92 
93 }
94 
95 #endif
#define OSG_EXPORT
Definition: Export.h:43
virtual int compare(const StateAttribute &sa) const
Definition: TexEnv.h:58
virtual bool isTextureAttribute() const
Definition: TexEnv.h:55
#define COMPARE_StateAttribute_Types(TYPE, rhs_attribute)
Vec4 & getColor()
Definition: TexEnv.h:78
void setColor(const Vec4 &color)
Definition: TexEnv.h:76
TexEnv(const TexEnv &texenv, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition: TexEnv.h:47
#define GL_MODULATE
Definition: TexEnv.h:24
Mode _mode
Definition: TexEnv.h:89
Mode getMode() const
Definition: TexEnv.h:74
#define META_StateAttribute(library, name, type)
#define GL_ADD
Definition: TexEnv.h:23
void setMode(Mode mode)
Definition: TexEnv.h:72
const Vec4 & getColor() const
Definition: TexEnv.h:80
Definition: AlphaFunc.h:19
#define COMPARE_StateAttribute_Parameter(parameter)
#define GL_DECAL
Definition: TexEnv.h:25
osg::Vec4 _color
Definition: TexEnv.h:90