00001
00007 #include <stdlib.h>
00008 #include <stdio.h>
00009
00010 #include <OSGConfig.h>
00011
00012 #include <OSGGL.h>
00013
00014 #include "OSGTwoSidedLightingChunk.h"
00015 #include <OSGWindow.h>
00016 #include <OSGDrawActionBase.h>
00017 #include <OSGCamera.h>
00018 #include <OSGTextureChunk.h>
00019
00020 OSG_USING_NAMESPACE
00021
00022
00023
00024
00025
00026 StateChunkClass TwoSidedLightingChunk::_class("TwoSidedLighting");
00027
00028
00029
00030
00031
00032 void TwoSidedLightingChunk::initMethod (void)
00033 {
00034 }
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 TwoSidedLightingChunk::TwoSidedLightingChunk(void) :
00045 Inherited(),
00046 _state(GL_FALSE)
00047 {
00048 }
00049
00050 TwoSidedLightingChunk::TwoSidedLightingChunk(const TwoSidedLightingChunk &source) :
00051 Inherited(source),
00052 _state(source._state)
00053 {
00054 }
00055
00056 TwoSidedLightingChunk::~TwoSidedLightingChunk(void)
00057 {
00058 }
00059
00060
00061
00062 const StateChunkClass *TwoSidedLightingChunk::getClass(void) const
00063 {
00064 return &_class;
00065 }
00066
00067
00068
00069 void TwoSidedLightingChunk::changed(BitVector whichField, UInt32 origin)
00070 {
00071 Inherited::changed(whichField, origin);
00072 }
00073
00074
00075
00076 void TwoSidedLightingChunk::dump( UInt32 ,
00077 const BitVector ) const
00078 {
00079 SLOG << "Dump TwoSidedLightingChunk NI" << std::endl;
00080 }
00081
00082
00083
00084 void TwoSidedLightingChunk::activate ( DrawActionBase * action, UInt32 idx )
00085 {
00086 glGetBooleanv(GL_LIGHT_MODEL_TWO_SIDE, &_state);
00087 if(_state == GL_FALSE)
00088 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
00089 }
00090
00091 void TwoSidedLightingChunk::changeFrom( DrawActionBase *action, StateChunk *old_chunk, UInt32 idx )
00092 {
00093 TwoSidedLightingChunk *old = dynamic_cast<TwoSidedLightingChunk *>(old_chunk);
00094
00095 if(old == NULL)
00096 {
00097 FWARNING(( "TwoSidedLightingChunk::changeFrom: caught non-TwoSidedLightingChunk!\n"));
00098 return;
00099 }
00100
00101
00102 if(old == this)
00103 return;
00104
00105 _state = old->_state;
00106
00107 if(_state == GL_FALSE)
00108 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
00109 }
00110
00111 void TwoSidedLightingChunk::deactivate ( DrawActionBase * action, UInt32 idx )
00112 {
00113 GLboolean tsl = GL_FALSE;
00114 glGetBooleanv(GL_LIGHT_MODEL_TWO_SIDE, &tsl);
00115 if(_state != tsl)
00116 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, _state);
00117 }
00118
00119
00120
00121
00122 Real32 TwoSidedLightingChunk::switchCost(StateChunk *OSG_CHECK_ARG(chunk))
00123 {
00124 return 0;
00125 }
00126
00127 bool TwoSidedLightingChunk::operator <(const StateChunk &other) const
00128 {
00129 return this < &other;
00130 }
00131
00132 bool TwoSidedLightingChunk::operator ==(const StateChunk &other) const
00133 {
00134 TwoSidedLightingChunk const *tother =
00135 dynamic_cast<TwoSidedLightingChunk const*>(&other);
00136
00137 if(!tother)
00138 return false;
00139
00140 if(tother == this)
00141 return true;
00142
00143 return true;
00144 }
00145
00146 bool TwoSidedLightingChunk::operator !=(const StateChunk &other) const
00147 {
00148 return !(*this == other);
00149 }
00150
00151
00152
00153
00154
00155 #ifdef __sgi
00156 #pragma set woff 1174
00157 #endif
00158
00159 #ifdef OSG_LINUX_ICC
00160 #pragma warning( disable : 177 )
00161 #endif
00162
00163 namespace
00164 {
00165 static char cvsid_cpp[] = "@(#)$Id: OSGTwoSidedLightingChunk.cpp,v 1.1 2005/06/09 08:39:27 a-m-z Exp $";
00166 static char cvsid_hpp[] = OSGTWOSIDEDLIGHTINGCHUNK_HEADER_CVSID;
00167 static char cvsid_inl[] = OSGTWOSIDEDLIGHTINGCHUNK_HEADER_CVSID;
00168 }