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
00040
00041
00042
00043 #include <stdlib.h>
00044 #include <stdio.h>
00045
00046 #include "OSGConfig.h"
00047
00048 #include <OSGGL.h>
00049
00050 #include "OSGPolygonChunk.h"
00051
00052 OSG_USING_NAMESPACE
00053
00054
00055
00056
00057
00058
00077
00078
00079
00080
00081 StateChunkClass PolygonChunk::_class("Polygon");
00082
00083
00084
00085
00086
00087 void PolygonChunk::initMethod (void)
00088 {
00089 }
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 PolygonChunk::PolygonChunk(void) :
00103 Inherited()
00104 {
00105 }
00106
00107 PolygonChunk::PolygonChunk(const PolygonChunk &source) :
00108 Inherited(source)
00109 {
00110 }
00111
00112 PolygonChunk::~PolygonChunk(void)
00113 {
00114 }
00115
00116
00117
00118 const StateChunkClass *PolygonChunk::getClass(void) const
00119 {
00120 return &_class;
00121 }
00122
00123
00124
00125 void PolygonChunk::changed(BitVector whichField, UInt32 origin)
00126 {
00127 Inherited::changed(whichField, origin);
00128 }
00129
00130
00131
00132 void PolygonChunk::dump( UInt32 uiIndent,
00133 const BitVector bvFlags) const
00134 {
00135 Inherited::dump(uiIndent, bvFlags);
00136 }
00137
00138
00139
00140
00141 void PolygonChunk::activate(DrawActionBase *, UInt32)
00142 {
00143
00144
00145 if(_sfCullFace.getValue() != GL_NONE)
00146 {
00147 glCullFace(_sfCullFace.getValue());
00148 glEnable(GL_CULL_FACE);
00149 }
00150
00151
00152
00153 if(_sfFrontFace.getValue() != GL_CCW)
00154 glFrontFace(_sfFrontFace.getValue());
00155
00156
00157
00158 if(_sfSmooth.getValue())
00159 glEnable(GL_POLYGON_SMOOTH);
00160
00161
00162
00163 if(_sfFrontMode.getValue() != GL_FILL)
00164 glPolygonMode(GL_FRONT, _sfFrontMode.getValue());
00165
00166 if(_sfBackMode.getValue() != GL_FILL)
00167 glPolygonMode(GL_BACK, _sfBackMode.getValue());
00168
00169
00170
00171 if(_sfOffsetFactor.getValue() != 0.f || _sfOffsetBias.getValue() != 0.f)
00172 glPolygonOffset(_sfOffsetFactor.getValue(), _sfOffsetBias.getValue());
00173
00174 if(_sfOffsetPoint.getValue())
00175 glEnable(GL_POLYGON_OFFSET_POINT);
00176
00177 if(_sfOffsetLine.getValue())
00178 glEnable(GL_POLYGON_OFFSET_LINE);
00179
00180 if(_sfOffsetFill.getValue())
00181 glEnable(GL_POLYGON_OFFSET_FILL);
00182
00183
00184
00185 if(_mfStipple.size() == 32)
00186 {
00187 glPolygonStipple((const GLubyte *) &(_mfStipple[0]));
00188 glEnable(GL_POLYGON_STIPPLE);
00189 }
00190 }
00191
00192
00193 void PolygonChunk::changeFrom(DrawActionBase *, StateChunk * old_chunk, UInt32)
00194 {
00195 PolygonChunk const *old = dynamic_cast<PolygonChunk const*>(old_chunk);
00196
00197
00198
00199 if(old == this)
00200 return;
00201
00202
00203
00204 if(_sfCullFace.getValue() != old->_sfCullFace.getValue())
00205 {
00206 if(_sfCullFace.getValue() != GL_NONE)
00207 {
00208 glCullFace(_sfCullFace.getValue());
00209 glEnable(GL_CULL_FACE);
00210 }
00211 else
00212 {
00213 glDisable(GL_CULL_FACE);
00214 }
00215 }
00216
00217
00218
00219 if(_sfFrontFace.getValue() != old->_sfFrontFace.getValue())
00220 {
00221 glFrontFace(_sfFrontFace.getValue());
00222 }
00223
00224
00225
00226 if(_sfSmooth.getValue() != old->_sfSmooth.getValue())
00227 {
00228 if(_sfSmooth.getValue())
00229 {
00230 glEnable(GL_POLYGON_SMOOTH);
00231 }
00232 else
00233 {
00234 glDisable(GL_POLYGON_SMOOTH);
00235 }
00236 }
00237
00238
00239
00240 if(_sfFrontMode.getValue() != old->_sfFrontMode.getValue())
00241 glPolygonMode(GL_FRONT, _sfFrontMode.getValue());
00242
00243 if(_sfBackMode.getValue() != old->_sfBackMode.getValue())
00244 glPolygonMode(GL_BACK, _sfBackMode.getValue());
00245
00246
00247
00248 if(_sfOffsetFactor.getValue() != old->_sfOffsetFactor.getValue() ||
00249 _sfOffsetBias.getValue() != old->_sfOffsetBias.getValue())
00250 {
00251 glPolygonOffset(_sfOffsetFactor.getValue(), _sfOffsetBias.getValue());
00252 }
00253
00254 if(_sfOffsetPoint.getValue() != old->_sfOffsetPoint.getValue())
00255 {
00256 if(_sfOffsetPoint.getValue())
00257 {
00258 glEnable(GL_POLYGON_OFFSET_POINT);
00259 }
00260 else
00261 {
00262 glDisable(GL_POLYGON_OFFSET_POINT);
00263 }
00264 }
00265
00266 if(_sfOffsetLine.getValue() != old->_sfOffsetLine.getValue())
00267 {
00268 if(_sfOffsetLine.getValue())
00269 {
00270 glEnable(GL_POLYGON_OFFSET_LINE);
00271 }
00272 else
00273 {
00274 glDisable(GL_POLYGON_OFFSET_LINE);
00275 }
00276 }
00277
00278 if(_sfOffsetFill.getValue() != old->_sfOffsetFill.getValue())
00279 {
00280 if(_sfOffsetFill.getValue())
00281 {
00282 glEnable(GL_POLYGON_OFFSET_FILL);
00283 }
00284 else
00285 {
00286 glDisable(GL_POLYGON_OFFSET_FILL);
00287 }
00288 }
00289
00290
00291
00292 if(_mfStipple.getValues() != old->_mfStipple.getValues())
00293 {
00294 if(_mfStipple.size() == 32)
00295 {
00296 glPolygonStipple((const GLubyte *) &(_mfStipple[0]));
00297 glEnable(GL_POLYGON_STIPPLE);
00298 }
00299 else glDisable(GL_POLYGON_STIPPLE);
00300 }
00301
00302 }
00303
00304 void PolygonChunk::deactivate(DrawActionBase *, UInt32)
00305 {
00306
00307
00308
00309 if(_sfCullFace.getValue() != GL_NONE)
00310 glDisable(GL_CULL_FACE);
00311
00312
00313
00314 if(_sfFrontFace.getValue() != GL_CCW)
00315 glFrontFace(GL_CCW);
00316
00317
00318
00319 if(_sfSmooth.getValue())
00320 glDisable(GL_POLYGON_SMOOTH);
00321
00322
00323
00324 if(_sfFrontMode.getValue() != GL_FILL)
00325 glPolygonMode(GL_FRONT, GL_FILL);
00326
00327 if(_sfBackMode.getValue() != GL_FILL)
00328 glPolygonMode(GL_BACK, GL_FILL);
00329
00330
00331
00332 if(_sfOffsetPoint.getValue())
00333 glDisable(GL_POLYGON_OFFSET_POINT);
00334
00335 if(_sfOffsetLine.getValue())
00336 glDisable(GL_POLYGON_OFFSET_LINE);
00337
00338 if(_sfOffsetFill.getValue())
00339 glDisable(GL_POLYGON_OFFSET_FILL);
00340
00341
00342
00343 if(_mfStipple.size() == 32)
00344 glDisable(GL_POLYGON_STIPPLE);
00345
00346 }
00347
00348
00349
00350
00351 Real32 PolygonChunk::switchCost(StateChunk *OSG_CHECK_ARG(chunk))
00352 {
00353 return 0;
00354 }
00355
00356 bool PolygonChunk::operator <(const StateChunk &other) const
00357 {
00358 return this < &other;
00359 }
00360
00361 bool PolygonChunk::operator ==(const StateChunk &other) const
00362 {
00363 PolygonChunk const *tother = dynamic_cast<PolygonChunk const*>(&other);
00364
00365 if(!tother)
00366 return false;
00367
00368 if(tother == this)
00369 return true;
00370
00371 if(getCullFace() != tother->getCullFace() ||
00372 getFrontFace() != tother->getFrontFace() ||
00373 getSmooth() != tother->getSmooth() ||
00374 getFrontMode() != tother->getFrontMode() ||
00375 getBackMode() != tother->getBackMode() ||
00376 getOffsetPoint() != tother->getOffsetPoint() ||
00377 getOffsetLine() != tother->getOffsetLine() ||
00378 getOffsetFill() != tother->getOffsetFill() ||
00379 getOffsetFactor() != tother->getOffsetFactor() ||
00380 getOffsetBias() != tother->getOffsetBias() ||
00381 getStipple().size() != tother->getStipple().size()
00382 )
00383 return false;
00384
00385
00386
00387
00388 if( getStipple().size() != 0 ||
00389 tother->getStipple().size() != 0
00390 )
00391 return false;
00392
00393 return true;
00394 }
00395
00396 bool PolygonChunk::operator !=(const StateChunk &other) const
00397 {
00398 return !(*this == other);
00399 }
00400
00401
00402
00403
00404 #ifdef OSG_SGI_CC
00405 #pragma set woff 1174
00406 #endif
00407
00408 #ifdef OSG_LINUX_ICC
00409 #pragma warning( disable : 177 )
00410 #endif
00411
00412 namespace
00413 {
00414 static Char8 cvsid_cpp [] = "@(#)$Id: FCTemplate_cpp.h,v 1.13 2002/06/01 10:37:25 vossg Exp $";
00415 static Char8 cvsid_hpp [] = OSGPOLYGONCHUNK_HEADER_CVSID;
00416 static Char8 cvsid_inl [] = OSGPOLYGONCHUNK_INLINE_CVSID;
00417
00418 static Char8 cvsid_fields_hpp[] = OSGPOLYGONCHUNKFIELDS_HEADER_CVSID;
00419 }
00420
00421 #ifdef __sgi
00422 #pragma reset woff 1174
00423 #endif
00424
00425