changed: gcc8 base update
[opensg.git] / Source / System / State / OpenGL / OSGFogChunk.cpp
blob336ca7d9cabb6914238b9983a53789754cc8b778
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 "OSGFogChunk.h"
49 #include "OSGDrawEnv.h"
51 OSG_BEGIN_NAMESPACE
53 // Documentation for this class is emitted in the
54 // OSGFogChunkBase.cpp file.
55 // To modify it, please change the .fcd file (OSGFogChunk.fcd) and
56 // regenerate the base file.
58 /***************************************************************************\
59 * Class variables *
60 \***************************************************************************/
62 StateChunkClass FogChunk::_class("Fog", 1, 100);
64 /***************************************************************************\
65 * Class methods *
66 \***************************************************************************/
68 void FogChunk::initMethod(InitPhase ePhase)
70 Inherited::initMethod(ePhase);
74 /***************************************************************************\
75 * Instance methods *
76 \***************************************************************************/
78 /*-------------------------------------------------------------------------*\
79 - private -
80 \*-------------------------------------------------------------------------*/
82 /*----------------------- constructors & destructors ----------------------*/
84 FogChunk::FogChunk(void) :
85 Inherited()
89 FogChunk::FogChunk(const FogChunk &source) :
90 Inherited(source)
94 FogChunk::~FogChunk(void)
98 /*----------------------------- class specific ----------------------------*/
100 const StateChunkClass *FogChunk::getClass(void) const
102 return &_class;
105 void FogChunk::activate(DrawEnv *pEnv, UInt32 /* index */)
107 #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
108 pEnv->incNumChunkChanges();
110 glFogi (GL_FOG_MODE, getMode () );
111 glFogf (GL_FOG_DENSITY, getDensity() );
112 glFogf (GL_FOG_START, getStart () );
113 glFogf (GL_FOG_END, getEnd () );
114 glFogfv(GL_FOG_COLOR, getColor ().getValuesRGBA());
116 glEnable(GL_FOG);
117 #else
118 OSG_ASSERT(false);
119 #endif
122 void FogChunk::changeFrom(DrawEnv *pEnv,
123 StateChunk *oldChunk,
124 UInt32 index )
126 oldChunk->deactivate(pEnv, index);
127 this ->activate (pEnv, index);
130 void FogChunk::deactivate(DrawEnv * /* pEnv */, UInt32 /* index */)
132 #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
133 glDisable(GL_FOG);
134 #else
135 OSG_ASSERT(false);
136 #endif
139 bool FogChunk::isTransparent(void) const
141 return false;
144 void FogChunk::changed(ConstFieldMaskArg whichField,
145 UInt32 origin,
146 BitVector details)
148 Inherited::changed(whichField, origin, details);
151 void FogChunk::dump( UInt32 ,
152 const BitVector ) const
154 SLOG << "Dump FogChunk NI" << std::endl;
157 Real32 FogChunk::switchCost(StateChunk * /* chunk */)
159 return 0;
162 bool FogChunk::operator < (const StateChunk &other) const
164 return this < &other;
167 bool FogChunk::operator == (const StateChunk &other) const
169 FogChunk const *tother = dynamic_cast<FogChunk const *>(&other);
171 if(tother == NULL)
172 return false;
174 if(getMode() != tother->getMode())
175 return false;
177 if(getDensity() != tother->getDensity())
178 return false;
180 if(getStart() != tother->getStart())
181 return false;
183 if(getEnd() != tother->getEnd())
184 return false;
186 if(getColor() != tother->getColor())
187 return false;
189 return true;
192 bool FogChunk::operator != (const StateChunk &other) const
194 return ! (*this == other);
197 OSG_END_NAMESPACE