1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
46 #include "OSGConfig.h"
48 #include "OSGFogChunk.h"
49 #include "OSGDrawEnv.h"
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 /***************************************************************************\
60 \***************************************************************************/
62 StateChunkClass
FogChunk::_class("Fog", 1, 100);
64 /***************************************************************************\
66 \***************************************************************************/
68 void FogChunk::initMethod(InitPhase ePhase
)
70 Inherited::initMethod(ePhase
);
74 /***************************************************************************\
76 \***************************************************************************/
78 /*-------------------------------------------------------------------------*\
80 \*-------------------------------------------------------------------------*/
82 /*----------------------- constructors & destructors ----------------------*/
84 FogChunk::FogChunk(void) :
89 FogChunk::FogChunk(const FogChunk
&source
) :
94 FogChunk::~FogChunk(void)
98 /*----------------------------- class specific ----------------------------*/
100 const StateChunkClass
*FogChunk::getClass(void) const
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());
122 void FogChunk::changeFrom(DrawEnv
*pEnv
,
123 StateChunk
*oldChunk
,
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)
139 bool FogChunk::isTransparent(void) const
144 void FogChunk::changed(ConstFieldMaskArg whichField
,
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 */)
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
);
174 if(getMode() != tother
->getMode())
177 if(getDensity() != tother
->getDensity())
180 if(getStart() != tother
->getStart())
183 if(getEnd() != tother
->getEnd())
186 if(getColor() != tother
->getColor())
192 bool FogChunk::operator != (const StateChunk
&other
) const
194 return ! (*this == other
);