1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
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.
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.
14#ifndef OSG_COLORMATRIX
15#define OSG_COLORMATRIX 1
18#include <osg/StateAttribute>
22/** Encapsulates OpenGL color matrix functionality. */
23class OSG_EXPORT ColorMatrix : public StateAttribute
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) {}
34 META_StateAttribute(osg, ColorMatrix, COLORMATRIX);
36 /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
37 virtual int compare(const StateAttribute& sa) const
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)
43 // Compare each parameter in turn against the rhs.
44 COMPARE_StateAttribute_Parameter(_matrix)
46 return 0; // Passed all the above comparison macros, so must be equal.
49 /** Sets the color matrix. */
50 inline void setMatrix(const Matrix& matrix) { _matrix = matrix; }
52 /** Gets the color matrix. */
53 inline Matrix& getMatrix() { return _matrix; }
55 /** Gets the const color matrix. */
56 inline const Matrix& getMatrix() const { return _matrix; }
58 /** Applies as OpenGL texture matrix. */
59 virtual void apply(State& state) const;
63 virtual ~ColorMatrix( void );