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
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 #define OSG_COMPILESHADERCHUNKINST
00055
00056 #include <stdlib.h>
00057 #include <stdio.h>
00058
00059 #include <OSGConfig.h>
00060
00061 #include "OSGShaderChunkBase.h"
00062 #include "OSGShaderChunk.h"
00063
00064
00065 OSG_BEGIN_NAMESPACE
00066
00067 const OSG::BitVector ShaderChunkBase::VertexProgramFieldMask =
00068 (TypeTraits<BitVector>::One << ShaderChunkBase::VertexProgramFieldId);
00069
00070 const OSG::BitVector ShaderChunkBase::FragmentProgramFieldMask =
00071 (TypeTraits<BitVector>::One << ShaderChunkBase::FragmentProgramFieldId);
00072
00073 const OSG::BitVector ShaderChunkBase::GeometryProgramFieldMask =
00074 (TypeTraits<BitVector>::One << ShaderChunkBase::GeometryProgramFieldId);
00075
00076 const OSG::BitVector ShaderChunkBase::MTInfluenceMask =
00077 (Inherited::MTInfluenceMask) |
00078 (static_cast<BitVector>(0x0) << Inherited::NextFieldId);
00079
00080
00081
00082
00093
00094
00095 FieldDescription *ShaderChunkBase::_desc[] =
00096 {
00097 new FieldDescription(SFString::getClassType(),
00098 "vertexProgram",
00099 VertexProgramFieldId, VertexProgramFieldMask,
00100 false,
00101 reinterpret_cast<FieldAccessMethod>(&ShaderChunkBase::editSFVertexProgram)),
00102 new FieldDescription(SFString::getClassType(),
00103 "fragmentProgram",
00104 FragmentProgramFieldId, FragmentProgramFieldMask,
00105 false,
00106 reinterpret_cast<FieldAccessMethod>(&ShaderChunkBase::editSFFragmentProgram)),
00107 new FieldDescription(SFString::getClassType(),
00108 "geometryProgram",
00109 GeometryProgramFieldId, GeometryProgramFieldMask,
00110 false,
00111 reinterpret_cast<FieldAccessMethod>(&ShaderChunkBase::editSFGeometryProgram))
00112 };
00113
00114
00115 FieldContainerType ShaderChunkBase::_type(
00116 "ShaderChunk",
00117 "ShaderParameterChunk",
00118 NULL,
00119 NULL,
00120 ShaderChunk::initMethod,
00121 _desc,
00122 sizeof(_desc));
00123
00124
00125
00126
00127
00128 FieldContainerType &ShaderChunkBase::getType(void)
00129 {
00130 return _type;
00131 }
00132
00133 const FieldContainerType &ShaderChunkBase::getType(void) const
00134 {
00135 return _type;
00136 }
00137
00138
00139 UInt32 ShaderChunkBase::getContainerSize(void) const
00140 {
00141 return sizeof(ShaderChunk);
00142 }
00143
00144
00145 #if !defined(OSG_FIXED_MFIELDSYNC)
00146 void ShaderChunkBase::executeSync( FieldContainer &other,
00147 const BitVector &whichField)
00148 {
00149 this->executeSyncImpl(static_cast<ShaderChunkBase *>(&other),
00150 whichField);
00151 }
00152 #else
00153 void ShaderChunkBase::executeSync( FieldContainer &other,
00154 const BitVector &whichField, const SyncInfo &sInfo )
00155 {
00156 this->executeSyncImpl((ShaderChunkBase *) &other, whichField, sInfo);
00157 }
00158 void ShaderChunkBase::execBeginEdit(const BitVector &whichField,
00159 UInt32 uiAspect,
00160 UInt32 uiContainerSize)
00161 {
00162 this->execBeginEditImpl(whichField, uiAspect, uiContainerSize);
00163 }
00164
00165 void ShaderChunkBase::onDestroyAspect(UInt32 uiId, UInt32 uiAspect)
00166 {
00167 Inherited::onDestroyAspect(uiId, uiAspect);
00168
00169 }
00170 #endif
00171
00172
00173
00174 #ifdef OSG_WIN32_ICL
00175 #pragma warning (disable : 383)
00176 #endif
00177
00178 ShaderChunkBase::ShaderChunkBase(void) :
00179 _sfVertexProgram (),
00180 _sfFragmentProgram (),
00181 _sfGeometryProgram (),
00182 Inherited()
00183 {
00184 }
00185
00186 #ifdef OSG_WIN32_ICL
00187 #pragma warning (default : 383)
00188 #endif
00189
00190 ShaderChunkBase::ShaderChunkBase(const ShaderChunkBase &source) :
00191 _sfVertexProgram (source._sfVertexProgram ),
00192 _sfFragmentProgram (source._sfFragmentProgram ),
00193 _sfGeometryProgram (source._sfGeometryProgram ),
00194 Inherited (source)
00195 {
00196 }
00197
00198
00199
00200 ShaderChunkBase::~ShaderChunkBase(void)
00201 {
00202 }
00203
00204
00205
00206 UInt32 ShaderChunkBase::getBinSize(const BitVector &whichField)
00207 {
00208 UInt32 returnValue = Inherited::getBinSize(whichField);
00209
00210 if(FieldBits::NoField != (VertexProgramFieldMask & whichField))
00211 {
00212 returnValue += _sfVertexProgram.getBinSize();
00213 }
00214
00215 if(FieldBits::NoField != (FragmentProgramFieldMask & whichField))
00216 {
00217 returnValue += _sfFragmentProgram.getBinSize();
00218 }
00219
00220 if(FieldBits::NoField != (GeometryProgramFieldMask & whichField))
00221 {
00222 returnValue += _sfGeometryProgram.getBinSize();
00223 }
00224
00225
00226 return returnValue;
00227 }
00228
00229 void ShaderChunkBase::copyToBin( BinaryDataHandler &pMem,
00230 const BitVector &whichField)
00231 {
00232 Inherited::copyToBin(pMem, whichField);
00233
00234 if(FieldBits::NoField != (VertexProgramFieldMask & whichField))
00235 {
00236 _sfVertexProgram.copyToBin(pMem);
00237 }
00238
00239 if(FieldBits::NoField != (FragmentProgramFieldMask & whichField))
00240 {
00241 _sfFragmentProgram.copyToBin(pMem);
00242 }
00243
00244 if(FieldBits::NoField != (GeometryProgramFieldMask & whichField))
00245 {
00246 _sfGeometryProgram.copyToBin(pMem);
00247 }
00248
00249
00250 }
00251
00252 void ShaderChunkBase::copyFromBin( BinaryDataHandler &pMem,
00253 const BitVector &whichField)
00254 {
00255 Inherited::copyFromBin(pMem, whichField);
00256
00257 if(FieldBits::NoField != (VertexProgramFieldMask & whichField))
00258 {
00259 _sfVertexProgram.copyFromBin(pMem);
00260 }
00261
00262 if(FieldBits::NoField != (FragmentProgramFieldMask & whichField))
00263 {
00264 _sfFragmentProgram.copyFromBin(pMem);
00265 }
00266
00267 if(FieldBits::NoField != (GeometryProgramFieldMask & whichField))
00268 {
00269 _sfGeometryProgram.copyFromBin(pMem);
00270 }
00271
00272
00273 }
00274
00275 #if !defined(OSG_FIXED_MFIELDSYNC)
00276 void ShaderChunkBase::executeSyncImpl( ShaderChunkBase *pOther,
00277 const BitVector &whichField)
00278 {
00279
00280 Inherited::executeSyncImpl(pOther, whichField);
00281
00282 if(FieldBits::NoField != (VertexProgramFieldMask & whichField))
00283 _sfVertexProgram.syncWith(pOther->_sfVertexProgram);
00284
00285 if(FieldBits::NoField != (FragmentProgramFieldMask & whichField))
00286 _sfFragmentProgram.syncWith(pOther->_sfFragmentProgram);
00287
00288 if(FieldBits::NoField != (GeometryProgramFieldMask & whichField))
00289 _sfGeometryProgram.syncWith(pOther->_sfGeometryProgram);
00290
00291
00292 }
00293 #else
00294 void ShaderChunkBase::executeSyncImpl( ShaderChunkBase *pOther,
00295 const BitVector &whichField,
00296 const SyncInfo &sInfo )
00297 {
00298
00299 Inherited::executeSyncImpl(pOther, whichField, sInfo);
00300
00301 if(FieldBits::NoField != (VertexProgramFieldMask & whichField))
00302 _sfVertexProgram.syncWith(pOther->_sfVertexProgram);
00303
00304 if(FieldBits::NoField != (FragmentProgramFieldMask & whichField))
00305 _sfFragmentProgram.syncWith(pOther->_sfFragmentProgram);
00306
00307 if(FieldBits::NoField != (GeometryProgramFieldMask & whichField))
00308 _sfGeometryProgram.syncWith(pOther->_sfGeometryProgram);
00309
00310
00311
00312 }
00313
00314 void ShaderChunkBase::execBeginEditImpl (const BitVector &whichField,
00315 UInt32 uiAspect,
00316 UInt32 uiContainerSize)
00317 {
00318 Inherited::execBeginEditImpl(whichField, uiAspect, uiContainerSize);
00319
00320 }
00321 #endif
00322
00323
00324
00325 OSG_END_NAMESPACE
00326
00327 #include <OSGSFieldTypeDef.inl>
00328 #include <OSGMFieldTypeDef.inl>
00329
00330 OSG_BEGIN_NAMESPACE
00331
00332 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
00333 DataType FieldDataTraits<ShaderChunkPtr>::_type("ShaderChunkPtr", "ShaderParameterChunkPtr");
00334 #endif
00335
00336 OSG_DLLEXPORT_SFIELD_DEF1(ShaderChunkPtr, OSG_SYSTEMLIB_DLLTMPLMAPPING);
00337 OSG_DLLEXPORT_MFIELD_DEF1(ShaderChunkPtr, OSG_SYSTEMLIB_DLLTMPLMAPPING);
00338
00339
00340
00341
00342
00343 #ifdef OSG_SGI_CC
00344 #pragma set woff 1174
00345 #endif
00346
00347 #ifdef OSG_LINUX_ICC
00348 #pragma warning( disable : 177 )
00349 #endif
00350
00351 namespace
00352 {
00353 static Char8 cvsid_cpp [] = "@(#)$Id: OSGShaderChunkBase.cpp,v 1.11 2008/06/09 12:28:05 vossg Exp $";
00354 static Char8 cvsid_hpp [] = OSGSHADERCHUNKBASE_HEADER_CVSID;
00355 static Char8 cvsid_inl [] = OSGSHADERCHUNKBASE_INLINE_CVSID;
00356
00357 static Char8 cvsid_fields_hpp[] = OSGSHADERCHUNKFIELDS_HEADER_CVSID;
00358 }
00359
00360 OSG_END_NAMESPACE
00361