openscenegraph
ColorMatrix
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_COLORMATRIX
15#define OSG_COLORMATRIX 1
16
17#include <osg/Matrix>
18#include <osg/StateAttribute>
19
20namespace osg {
21
22/** Encapsulates OpenGL color matrix functionality. */
23class OSG_EXPORT ColorMatrix : public StateAttribute
24{
25 public :
26
27 ColorMatrix();
28
29 /** Copy constructor using CopyOp to manage deep vs shallow copy. */
30 ColorMatrix(const ColorMatrix& cm,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
31 StateAttribute(cm,copyop),
32 _matrix(cm._matrix) {}
33
34 META_StateAttribute(osg, ColorMatrix, COLORMATRIX);
35
36 /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
37 virtual int compare(const StateAttribute& sa) const
38 {
39 // Check for equal types, then create the rhs variable
40 // used by the COMPARE_StateAttribute_Parameter macros below.
41 COMPARE_StateAttribute_Types(ColorMatrix,sa)
42
43 // Compare each parameter in turn against the rhs.
44 COMPARE_StateAttribute_Parameter(_matrix)
45
46 return 0; // Passed all the above comparison macros, so must be equal.
47 }
48
49 /** Sets the color matrix. */
50 inline void setMatrix(const Matrix& matrix) { _matrix = matrix; }
51
52 /** Gets the color matrix. */
53 inline Matrix& getMatrix() { return _matrix; }
54
55 /** Gets the const color matrix. */
56 inline const Matrix& getMatrix() const { return _matrix; }
57
58 /** Applies as OpenGL texture matrix. */
59 virtual void apply(State& state) const;
60
61 protected:
62
63 virtual ~ColorMatrix( void );
64
65 Matrix _matrix;
66
67};
68
69}
70
71
72#endif