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.
17#include <osg/StateAttribute>
19#ifndef OSG_GL_FIXED_FUNCTION_AVAILABLE
20 #define GL_CLEAR 0x1500
22 #define GL_COPY 0x1503
23 #define GL_COPY_INVERTED 0x150C
24 #define GL_NOOP 0x1505
26 #define GL_NAND 0x150E
30 #define GL_EQUIV 0x1509
31 #define GL_AND_REVERSE 0x1502
32 #define GL_AND_INVERTED 0x1504
33 #define GL_OR_REVERSE 0x150B
34 #define GL_OR_INVERTED 0x150D
35 #define GL_COLOR_LOGIC_OP 0x0BF2
40/** Encapsulates OpenGL LogicOp state. */
41class OSG_EXPORT LogicOp : public StateAttribute
49 COPY_INVERTED = GL_COPY_INVERTED,
58 AND_REVERSE = GL_AND_REVERSE,
59 AND_INVERTED = GL_AND_INVERTED,
60 OR_REVERSE = GL_OR_REVERSE,
61 OR_INVERTED = GL_OR_INVERTED
66 LogicOp(Opcode opcode);
68 /** Copy constructor using CopyOp to manage deep vs shallow copy. */
69 LogicOp(const LogicOp& trans,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
70 StateAttribute(trans,copyop),
71 _opcode(trans._opcode){}
73 META_StateAttribute(osg, LogicOp,LOGICOP);
75 /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
76 virtual int compare(const StateAttribute& sa) const
78 // Check for equal types, then create the rhs variable
79 // used by the COMPARE_StateAttribute_Parameter macros below.
80 COMPARE_StateAttribute_Types(LogicOp,sa)
82 // Compare each parameter in turn against the rhs.
83 COMPARE_StateAttribute_Parameter(_opcode)
85 return 0; // Passed all the above comparison macros, so must be equal.
88 virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
90 usage.usesMode(GL_COLOR_LOGIC_OP);
95 inline void setOpcode(Opcode opcode)
100 inline Opcode getOpcode() const { return _opcode; }
102 virtual void apply(State& state) const;