fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / OpenGL / OSGTwoSidedLightingChunk.cpp
blob39c7fef290305775d65bfaba6c4da910ef074adf
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 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 #include <cstdlib>
40 #include <cstdio>
42 #include "OSGConfig.h"
44 #include "OSGGL.h"
46 #include "OSGTwoSidedLightingChunk.h"
47 #include "OSGWindow.h"
48 #include "OSGCamera.h"
50 OSG_USING_NAMESPACE
52 // Documentation for this class is emited in the
53 // OSGTwoSidedLightingChunkBase.cpp file.
54 // To modify it, please change the .fcd file (OSGTwoSidedLightingChunk.fcd) and
55 // regenerate the base file.
57 /***************************************************************************\
58 * Class variables *
59 \***************************************************************************/
61 StateChunkClass TwoSidedLightingChunk::_class("TwoSidedLighting", 1, 100);
63 /***************************************************************************\
64 * Class methods *
65 \***************************************************************************/
67 void TwoSidedLightingChunk::initMethod(InitPhase ePhase)
69 Inherited::initMethod(ePhase);
72 /***************************************************************************\
73 * Instance methods *
74 \***************************************************************************/
76 /*-------------------------------------------------------------------------*\
77 - private -
78 \*-------------------------------------------------------------------------*/
80 TwoSidedLightingChunk::TwoSidedLightingChunk(void) :
81 Inherited( ),
82 _state (GL_FALSE)
86 TwoSidedLightingChunk::TwoSidedLightingChunk(
87 const TwoSidedLightingChunk &source) :
89 Inherited(source),
90 _state(source._state)
94 TwoSidedLightingChunk::~TwoSidedLightingChunk(void)
98 /*------------------------- Chunk Class Access ---------------------------*/
100 const StateChunkClass *TwoSidedLightingChunk::getClass(void) const
102 return &_class;
105 /*------------------------------- Sync -----------------------------------*/
107 void TwoSidedLightingChunk::changed(ConstFieldMaskArg whichField,
108 UInt32 origin,
109 BitVector details)
111 Inherited::changed(whichField, origin, details);
114 /*------------------------------ Output ----------------------------------*/
116 void TwoSidedLightingChunk::dump( UInt32 ,
117 const BitVector ) const
119 SLOG << "Dump TwoSidedLightingChunk NI" << std::endl;
122 /*------------------------------ State ------------------------------------*/
124 void TwoSidedLightingChunk::activate (DrawEnv *pEnv, UInt32 idx)
126 #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
127 pEnv->incNumChunkChanges();
129 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
130 #else
131 OSG_ASSERT(false);
132 #endif
135 void TwoSidedLightingChunk::changeFrom(DrawEnv *pEnv,
136 StateChunk *old_chunk,
137 UInt32 idx )
139 #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
140 TwoSidedLightingChunk *old =
141 dynamic_cast<TwoSidedLightingChunk *>(old_chunk);
143 if(old == NULL)
145 FWARNING(( "TwoSidedLightingChunk::changeFrom: "
146 "caught non-TwoSidedLightingChunk!\n"));
147 return;
150 // TwoSidedLightingChunk didn't change so do nothing.
151 if(old == this)
152 return;
154 pEnv->incNumChunkChanges();
156 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
157 #else
158 OSG_ASSERT(false);
159 #endif
162 void TwoSidedLightingChunk::deactivate(DrawEnv *pEnv, UInt32 idx)
164 #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
165 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
166 #else
167 OSG_ASSERT(false);
168 #endif
172 /*-------------------------- Comparison -----------------------------------*/
174 Real32 TwoSidedLightingChunk::switchCost(StateChunk *OSG_CHECK_ARG(chunk))
176 return 0;
179 bool TwoSidedLightingChunk::operator <(const StateChunk &other) const
181 return this < &other;
184 bool TwoSidedLightingChunk::operator ==(const StateChunk &other) const
186 TwoSidedLightingChunk const *tother =
187 dynamic_cast<TwoSidedLightingChunk const*>(&other);
189 if(!tother)
190 return false;
192 if(tother == this)
193 return true;
195 return true;
198 bool TwoSidedLightingChunk::operator !=(const StateChunk &other) const
200 return !(*this == other);