OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ClampColor.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_CLAMPCOLOR
15 #define OSG_CLAMPCOLOR 1
16 
17 #include <osg/StateAttribute>
18 
19 #ifndef GL_ARB_color_buffer_float
20 #define GL_RGBA_FLOAT_MODE_ARB 0x8820
21 #define GL_CLAMP_VERTEX_COLOR_ARB 0x891A
22 #define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B
23 #define GL_CLAMP_READ_COLOR_ARB 0x891C
24 #define GL_FIXED_ONLY_ARB 0x891D
25 #endif
26 
27 #ifndef GL_FIXED_ONLY
28 #define GL_FIXED_ONLY GL_FIXED_ONLY_ARB
29 #define GL_CLAMP_VERTEX_COLOR GL_CLAMP_VERTEX_COLOR_ARB
30 #define GL_CLAMP_READ_COLOR GL_CLAMP_READ_COLOR_ARB
31 #define GL_CLAMP_FRAGMENT_COLOR GL_CLAMP_FRAGMENT_COLOR_ARB
32 #endif
33 
34 #if defined(OSG_GL3_AVAILABLE)
35  #define GL_CLAMP_VERTEX_COLOR 0x891A
36  #define GL_CLAMP_FRAGMENT_COLOR 0x891B
37 #endif
38 
39 namespace osg {
40 
43 {
44  public :
45 
46  ClampColor();
47 
48  ClampColor(GLenum vertexMode, GLenum fragmentMode, GLenum readMode);
49 
51  ClampColor(const ClampColor& rhs,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
52  StateAttribute(rhs,copyop),
53  _clampVertexColor(rhs._clampVertexColor),
54  _clampFragmentColor(rhs._clampFragmentColor),
55  _clampReadColor(rhs._clampReadColor) {}
56 
57  META_StateAttribute(osg, ClampColor,CLAMPCOLOR);
58 
60  virtual int compare(const StateAttribute& sa) const
61  {
62  // Check for equal types, then create the rhs variable
63  // used by the COMPARE_StateAttribute_Parameter macros below.
65 
66  // Compare each parameter in turn against the rhs.
67  COMPARE_StateAttribute_Parameter(_clampVertexColor)
68  COMPARE_StateAttribute_Parameter(_clampFragmentColor)
69  COMPARE_StateAttribute_Parameter(_clampReadColor)
70 
71  return 0; // Passed all the above comparison macros, so must be equal.
72  }
73 
74  void setClampVertexColor(GLenum mode) { _clampVertexColor = mode; }
75  GLenum getClampVertexColor() const { return _clampVertexColor; }
76 
77  void setClampFragmentColor(GLenum mode) { _clampFragmentColor = mode; }
78  GLenum getClampFragmentColor() const { return _clampFragmentColor; }
79 
80  void setClampReadColor(GLenum mode) { _clampReadColor = mode; }
81  GLenum getClampReadColor() const { return _clampReadColor; }
82 
83  virtual void apply(State& state) const;
84 
85  protected :
86 
87  virtual ~ClampColor();
88 
92 
93 };
94 
95 }
96 
97 #endif
#define OSG_EXPORT
Definition: Export.h:43
void setClampVertexColor(GLenum mode)
Definition: ClampColor.h:74
virtual int compare(const StateAttribute &sa) const
Definition: ClampColor.h:60
#define COMPARE_StateAttribute_Types(TYPE, rhs_attribute)
void setClampFragmentColor(GLenum mode)
Definition: ClampColor.h:77
GLenum getClampFragmentColor() const
Definition: ClampColor.h:78
GLenum _clampVertexColor
Definition: ClampColor.h:89
GLenum getClampVertexColor() const
Definition: ClampColor.h:75
GLenum _clampReadColor
Definition: ClampColor.h:91
void setClampReadColor(GLenum mode)
Definition: ClampColor.h:80
GLenum getClampReadColor() const
Definition: ClampColor.h:81
#define META_StateAttribute(library, name, type)
ClampColor(const ClampColor &rhs, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition: ClampColor.h:51
Definition: AlphaFunc.h:19
#define COMPARE_StateAttribute_Parameter(parameter)
GLenum _clampFragmentColor
Definition: ClampColor.h:90