OSGTwoSidedLightingChunk.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include <cstdlib>
00040 #include <cstdio>
00041
00042 #include <OSGConfig.h>
00043
00044 #include <OSGGL.h>
00045
00046 #include "OSGTwoSidedLightingChunk.h"
00047 #include <OSGWindow.h>
00048 #include <OSGDrawActionBase.h>
00049 #include <OSGCamera.h>
00050
00051 OSG_USING_NAMESPACE
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 StateChunkClass TwoSidedLightingChunk::_class("TwoSidedLighting");
00063
00064
00065
00066
00067
00068 void TwoSidedLightingChunk::initMethod(InitPhase ePhase)
00069 {
00070 Inherited::initMethod(ePhase);
00071 }
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 TwoSidedLightingChunk::TwoSidedLightingChunk(void) :
00082 Inherited( ),
00083 _state (GL_FALSE)
00084 {
00085 }
00086
00087 TwoSidedLightingChunk::TwoSidedLightingChunk(
00088 const TwoSidedLightingChunk &source) :
00089
00090 Inherited(source),
00091 _state(source._state)
00092 {
00093 }
00094
00095 TwoSidedLightingChunk::~TwoSidedLightingChunk(void)
00096 {
00097 }
00098
00099
00100
00101 const StateChunkClass *TwoSidedLightingChunk::getClass(void) const
00102 {
00103 return &_class;
00104 }
00105
00106
00107
00108 void TwoSidedLightingChunk::changed(ConstFieldMaskArg whichField,
00109 UInt32 origin,
00110 BitVector details)
00111 {
00112 Inherited::changed(whichField, origin, details);
00113 }
00114
00115
00116
00117 void TwoSidedLightingChunk::dump( UInt32 ,
00118 const BitVector ) const
00119 {
00120 SLOG << "Dump TwoSidedLightingChunk NI" << std::endl;
00121 }
00122
00123
00124
00125 void TwoSidedLightingChunk::activate (DrawEnv *pEnv, UInt32 idx)
00126 {
00127 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
00128 }
00129
00130 void TwoSidedLightingChunk::changeFrom(DrawEnv *pEnv,
00131 StateChunk *old_chunk,
00132 UInt32 idx )
00133 {
00134 TwoSidedLightingChunk *old =
00135 dynamic_cast<TwoSidedLightingChunk *>(old_chunk);
00136
00137 if(old == NULL)
00138 {
00139 FWARNING(( "TwoSidedLightingChunk::changeFrom: "
00140 "caught non-TwoSidedLightingChunk!\n"));
00141 return;
00142 }
00143
00144
00145 if(old == this)
00146 return;
00147
00148 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
00149 }
00150
00151 void TwoSidedLightingChunk::deactivate(DrawEnv *pEnv, UInt32 idx)
00152 {
00153 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
00154 }
00155
00156
00157
00158
00159 Real32 TwoSidedLightingChunk::switchCost(StateChunk *OSG_CHECK_ARG(chunk))
00160 {
00161 return 0;
00162 }
00163
00164 bool TwoSidedLightingChunk::operator <(const StateChunk &other) const
00165 {
00166 return this < &other;
00167 }
00168
00169 bool TwoSidedLightingChunk::operator ==(const StateChunk &other) const
00170 {
00171 TwoSidedLightingChunk const *tother =
00172 dynamic_cast<TwoSidedLightingChunk const*>(&other);
00173
00174 if(!tother)
00175 return false;
00176
00177 if(tother == this)
00178 return true;
00179
00180 return true;
00181 }
00182
00183 bool TwoSidedLightingChunk::operator !=(const StateChunk &other) const
00184 {
00185 return !(*this == other);
00186 }