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 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
00087 }
00088
00089 void TwoSidedLightingChunk::changeFrom( DrawActionBase *action, StateChunk *old_chunk, UInt32 idx )
00090 {
00091 TwoSidedLightingChunk *old = dynamic_cast<TwoSidedLightingChunk *>(old_chunk);
00092
00093 if(old == NULL)
00094 {
00095 FWARNING(( "TwoSidedLightingChunk::changeFrom: caught non-TwoSidedLightingChunk!\n"));
00096 return;
00097 }
00098
00099
00100 if(old == this)
00101 return;
00102
00103 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
00104 }
00105
00106 void TwoSidedLightingChunk::deactivate ( DrawActionBase * action, UInt32 idx )
00107 {
00108 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
00109 }
00110
00111
00112
00113
00114 Real32 TwoSidedLightingChunk::switchCost(StateChunk *OSG_CHECK_ARG(chunk))
00115 {
00116 return 0;
00117 }
00118
00119 bool TwoSidedLightingChunk::operator <(const StateChunk &other) const
00120 {
00121 return this < &other;
00122 }
00123
00124 bool TwoSidedLightingChunk::operator ==(const StateChunk &other) const
00125 {
00126 TwoSidedLightingChunk const *tother =
00127 dynamic_cast<TwoSidedLightingChunk const*>(&other);
00128
00129 if(!tother)
00130 return false;
00131
00132 if(tother == this)
00133 return true;
00134
00135 return true;
00136 }
00137
00138 bool TwoSidedLightingChunk::operator !=(const StateChunk &other) const
00139 {
00140 return !(*this == other);
00141 }
00142
00143
00144
00145
00146
00147 #ifdef __sgi
00148 #pragma set woff 1174
00149 #endif
00150
00151 #ifdef OSG_LINUX_ICC
00152 #pragma warning( disable : 177 )
00153 #endif
00154
00155 namespace
00156 {
00157 static char cvsid_cpp[] = "@(#)$Id: OSGTwoSidedLightingChunk.cpp,v 1.2 2006/04/25 05:49:02 dirk Exp $";
00158 static char cvsid_hpp[] = OSGTWOSIDEDLIGHTINGCHUNK_HEADER_CVSID;
00159 static char cvsid_inl[] = OSGTWOSIDEDLIGHTINGCHUNK_HEADER_CVSID;
00160 }