changed: gcc8 base update
[opensg.git] / Source / System / State / OpenGL / OSGLogicOpChunk.cpp
blob66a05e83532687c18c9900e57cfcc35d3f02b809
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
40 // Includes
41 //---------------------------------------------------------------------------
43 #include <cstdlib>
44 #include <cstdio>
46 #include "OSGConfig.h"
48 #include "OSGLogicOpChunk.h"
49 #include "OSGDrawEnv.h"
51 OSG_BEGIN_NAMESPACE
53 // Documentation for this class is emitted in the
54 // OSGLogicOpChunkBase.cpp file.
55 // To modify it, please change the .fcd file (OSGLogicOpChunk.fcd) and
56 // regenerate the base file.
58 /***************************************************************************\
59 * Class variables *
60 \***************************************************************************/
62 #ifndef OSG_OGL_ES2
63 StateChunkClass LogicOpChunk::_class("LogicOp", 1, 50);
64 #else
65 StateChunkClass LogicOpChunk::_class("LogicOp", 1, 110);
66 #endif
68 /***************************************************************************\
69 * Class methods *
70 \***************************************************************************/
72 void LogicOpChunk::initMethod(InitPhase ePhase)
74 Inherited::initMethod(ePhase);
78 /***************************************************************************\
79 * Instance methods *
80 \***************************************************************************/
82 /*------------------------- Chunk Class Access ---------------------------*/
84 const StateChunkClass *LogicOpChunk::getClass(void) const
86 return &_class;
89 /*--------------------------------- Sync ---------------------------------*/
91 void LogicOpChunk::changed(ConstFieldMaskArg whichField,
92 UInt32 origin,
93 BitVector details)
95 Inherited::changed(whichField, origin, details);
98 /*-------------------------------- Output --------------------------------*/
100 void LogicOpChunk::dump( UInt32 ,
101 const BitVector ) const
103 SLOG << "Dump LogicOpChunk NI" << std::endl;
106 /*----------------------------- State Commands ---------------------------*/
108 void LogicOpChunk::activate(DrawEnv *pEnv, UInt32 index)
110 #ifndef OSG_OGL_ES2
111 pEnv->incNumChunkChanges();
113 if(_sfLogicOp.getValue() != GL_COPY)
115 glLogicOp(_sfLogicOp.getValue());
116 glEnable (GL_COLOR_LOGIC_OP );
118 #endif
121 void LogicOpChunk::changeFrom(DrawEnv *pEnv,
122 StateChunk *old,
123 UInt32 index )
125 old ->deactivate(pEnv, index);
126 this->activate (pEnv, index);
129 void LogicOpChunk::deactivate(DrawEnv *pEnv, UInt32 index)
131 #ifndef OSG_OGL_ES2
132 if(_sfLogicOp.getValue() != GL_COPY)
134 glDisable(GL_COLOR_LOGIC_OP);
135 glLogicOp(GL_COPY );
137 #endif
140 /*------------------------------- Comparison -----------------------------*/
142 Real32 LogicOpChunk::switchCost(StateChunk *chunk)
144 return 0.f;
147 bool LogicOpChunk::operator < (const StateChunk &other) const
149 return this < &other;
152 bool LogicOpChunk::operator == (const StateChunk &other) const
154 LogicOpChunk const *tOther = dynamic_cast<LogicOpChunk const *>(&other);
156 if(tOther == NULL)
157 return false;
159 if(tOther == this)
160 return true;
162 if(getLogicOp() != tOther->getLogicOp())
163 return false;
165 return true;
168 bool LogicOpChunk::operator != (const StateChunk &other) const
170 return !(*this == other);
173 /*-------------------------------------------------------------------------*\
174 - private -
175 \*-------------------------------------------------------------------------*/
177 /*----------------------- constructors & destructors ----------------------*/
179 LogicOpChunk::LogicOpChunk(void) :
180 Inherited()
184 LogicOpChunk::LogicOpChunk(const LogicOpChunk &source) :
185 Inherited(source)
189 LogicOpChunk::~LogicOpChunk(void)
193 /*----------------------------- class specific ----------------------------*/
195 OSG_END_NAMESPACE