1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 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 \*---------------------------------------------------------------------------*/
42 #include "OSGConfig.h"
46 #include "OSGTwoSidedLightingChunk.h"
47 #include "OSGWindow.h"
48 #include "OSGCamera.h"
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 /***************************************************************************\
59 \***************************************************************************/
61 StateChunkClass
TwoSidedLightingChunk::_class("TwoSidedLighting", 1, 100);
63 /***************************************************************************\
65 \***************************************************************************/
67 void TwoSidedLightingChunk::initMethod(InitPhase ePhase
)
69 Inherited::initMethod(ePhase
);
72 /***************************************************************************\
74 \***************************************************************************/
76 /*-------------------------------------------------------------------------*\
78 \*-------------------------------------------------------------------------*/
80 TwoSidedLightingChunk::TwoSidedLightingChunk(void) :
86 TwoSidedLightingChunk::TwoSidedLightingChunk(
87 const TwoSidedLightingChunk
&source
) :
94 TwoSidedLightingChunk::~TwoSidedLightingChunk(void)
98 /*------------------------- Chunk Class Access ---------------------------*/
100 const StateChunkClass
*TwoSidedLightingChunk::getClass(void) const
105 /*------------------------------- Sync -----------------------------------*/
107 void TwoSidedLightingChunk::changed(ConstFieldMaskArg whichField
,
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
);
135 void TwoSidedLightingChunk::changeFrom(DrawEnv
*pEnv
,
136 StateChunk
*old_chunk
,
139 #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
140 TwoSidedLightingChunk
*old
=
141 dynamic_cast<TwoSidedLightingChunk
*>(old_chunk
);
145 FWARNING(( "TwoSidedLightingChunk::changeFrom: "
146 "caught non-TwoSidedLightingChunk!\n"));
150 // TwoSidedLightingChunk didn't change so do nothing.
154 pEnv
->incNumChunkChanges();
156 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE
, GL_TRUE
);
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
);
172 /*-------------------------- Comparison -----------------------------------*/
174 Real32
TwoSidedLightingChunk::switchCost(StateChunk
*OSG_CHECK_ARG(chunk
))
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
);
198 bool TwoSidedLightingChunk::operator !=(const StateChunk
&other
) const
200 return !(*this == other
);