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 (FieldAccessMethod) &ShaderChunkBase::getSFVertexProgram),
00102 new FieldDescription(SFString::getClassType(),
00103 "fragmentProgram",
00104 FragmentProgramFieldId, FragmentProgramFieldMask,
00105 false,
00106 (FieldAccessMethod) &ShaderChunkBase::getSFFragmentProgram),
00107 new FieldDescription(SFString::getClassType(),
00108 "geometryProgram",
00109 GeometryProgramFieldId, GeometryProgramFieldMask,
00110 false,
00111 (FieldAccessMethod) &ShaderChunkBase::getSFGeometryProgram)
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((ShaderChunkBase *) &other, whichField);
00150 }
00151 #else
00152 void ShaderChunkBase::executeSync( FieldContainer &other,
00153 const BitVector &whichField, const SyncInfo &sInfo )
00154 {
00155 this->executeSyncImpl((ShaderChunkBase *) &other, whichField, sInfo);
00156 }
00157 void ShaderChunkBase::execBeginEdit(const BitVector &whichField,
00158 UInt32 uiAspect,
00159 UInt32 uiContainerSize)
00160 {
00161 this->execBeginEditImpl(whichField, uiAspect, uiContainerSize);
00162 }
00163
00164 void ShaderChunkBase::onDestroyAspect(UInt32 uiId, UInt32 uiAspect)
00165 {
00166 Inherited::onDestroyAspect(uiId, uiAspect);
00167
00168 }
00169 #endif
00170
00171
00172
00173 #ifdef OSG_WIN32_ICL
00174 #pragma warning (disable : 383)
00175 #endif
00176
00177 ShaderChunkBase::ShaderChunkBase(void) :
00178 _sfVertexProgram (),
00179 _sfFragmentProgram (),
00180 _sfGeometryProgram (),
00181 Inherited()
00182 {
00183 }
00184
00185 #ifdef OSG_WIN32_ICL
00186 #pragma warning (default : 383)
00187 #endif
00188
00189 ShaderChunkBase::ShaderChunkBase(const ShaderChunkBase &source) :
00190 _sfVertexProgram (source._sfVertexProgram ),
00191 _sfFragmentProgram (source._sfFragmentProgram ),
00192 _sfGeometryProgram (source._sfGeometryProgram ),
00193 Inherited (source)
00194 {
00195 }
00196
00197
00198
00199 ShaderChunkBase::~ShaderChunkBase(void)
00200 {
00201 }
00202
00203
00204
00205 UInt32 ShaderChunkBase::getBinSize(const BitVector &whichField)
00206 {
00207 UInt32 returnValue = Inherited::getBinSize(whichField);
00208
00209 if(FieldBits::NoField != (VertexProgramFieldMask & whichField))
00210 {
00211 returnValue += _sfVertexProgram.getBinSize();
00212 }
00213
00214 if(FieldBits::NoField != (FragmentProgramFieldMask & whichField))
00215 {
00216 returnValue += _sfFragmentProgram.getBinSize();
00217 }
00218
00219 if(FieldBits::NoField != (GeometryProgramFieldMask & whichField))
00220 {
00221 returnValue += _sfGeometryProgram.getBinSize();
00222 }
00223
00224
00225 return returnValue;
00226 }
00227
00228 void ShaderChunkBase::copyToBin( BinaryDataHandler &pMem,
00229 const BitVector &whichField)
00230 {
00231 Inherited::copyToBin(pMem, whichField);
00232
00233 if(FieldBits::NoField != (VertexProgramFieldMask & whichField))
00234 {
00235 _sfVertexProgram.copyToBin(pMem);
00236 }
00237
00238 if(FieldBits::NoField != (FragmentProgramFieldMask & whichField))
00239 {
00240 _sfFragmentProgram.copyToBin(pMem);
00241 }
00242
00243 if(FieldBits::NoField != (GeometryProgramFieldMask & whichField))
00244 {
00245 _sfGeometryProgram.copyToBin(pMem);
00246 }
00247
00248
00249 }
00250
00251 void ShaderChunkBase::copyFromBin( BinaryDataHandler &pMem,
00252 const BitVector &whichField)
00253 {
00254 Inherited::copyFromBin(pMem, whichField);
00255
00256 if(FieldBits::NoField != (VertexProgramFieldMask & whichField))
00257 {
00258 _sfVertexProgram.copyFromBin(pMem);
00259 }
00260
00261 if(FieldBits::NoField != (FragmentProgramFieldMask & whichField))
00262 {
00263 _sfFragmentProgram.copyFromBin(pMem);
00264 }
00265
00266 if(FieldBits::NoField != (GeometryProgramFieldMask & whichField))
00267 {
00268 _sfGeometryProgram.copyFromBin(pMem);
00269 }
00270
00271
00272 }
00273
00274 #if !defined(OSG_FIXED_MFIELDSYNC)
00275 void ShaderChunkBase::executeSyncImpl( ShaderChunkBase *pOther,
00276 const BitVector &whichField)
00277 {
00278
00279 Inherited::executeSyncImpl(pOther, whichField);
00280
00281 if(FieldBits::NoField != (VertexProgramFieldMask & whichField))
00282 _sfVertexProgram.syncWith(pOther->_sfVertexProgram);
00283
00284 if(FieldBits::NoField != (FragmentProgramFieldMask & whichField))
00285 _sfFragmentProgram.syncWith(pOther->_sfFragmentProgram);
00286
00287 if(FieldBits::NoField != (GeometryProgramFieldMask & whichField))
00288 _sfGeometryProgram.syncWith(pOther->_sfGeometryProgram);
00289
00290
00291 }
00292 #else
00293 void ShaderChunkBase::executeSyncImpl( ShaderChunkBase *pOther,
00294 const BitVector &whichField,
00295 const SyncInfo &sInfo )
00296 {
00297
00298 Inherited::executeSyncImpl(pOther, whichField, sInfo);
00299
00300 if(FieldBits::NoField != (VertexProgramFieldMask & whichField))
00301 _sfVertexProgram.syncWith(pOther->_sfVertexProgram);
00302
00303 if(FieldBits::NoField != (FragmentProgramFieldMask & whichField))
00304 _sfFragmentProgram.syncWith(pOther->_sfFragmentProgram);
00305
00306 if(FieldBits::NoField != (GeometryProgramFieldMask & whichField))
00307 _sfGeometryProgram.syncWith(pOther->_sfGeometryProgram);
00308
00309
00310
00311 }
00312
00313 void ShaderChunkBase::execBeginEditImpl (const BitVector &whichField,
00314 UInt32 uiAspect,
00315 UInt32 uiContainerSize)
00316 {
00317 Inherited::execBeginEditImpl(whichField, uiAspect, uiContainerSize);
00318
00319 }
00320 #endif
00321
00322
00323
00324 OSG_END_NAMESPACE
00325
00326 #include <OSGSFieldTypeDef.inl>
00327 #include <OSGMFieldTypeDef.inl>
00328
00329 OSG_BEGIN_NAMESPACE
00330
00331 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
00332 DataType FieldDataTraits<ShaderChunkPtr>::_type("ShaderChunkPtr", "ShaderParameterChunkPtr");
00333 #endif
00334
00335 OSG_DLLEXPORT_SFIELD_DEF1(ShaderChunkPtr, OSG_SYSTEMLIB_DLLTMPLMAPPING);
00336 OSG_DLLEXPORT_MFIELD_DEF1(ShaderChunkPtr, OSG_SYSTEMLIB_DLLTMPLMAPPING);
00337
00338
00339
00340
00341
00342 #ifdef OSG_SGI_CC
00343 #pragma set woff 1174
00344 #endif
00345
00346 #ifdef OSG_LINUX_ICC
00347 #pragma warning( disable : 177 )
00348 #endif
00349
00350 namespace
00351 {
00352 static Char8 cvsid_cpp [] = "@(#)$Id: OSGShaderChunkBase.cpp,v 1.8 2006/11/17 17:16:04 a-m-z Exp $";
00353 static Char8 cvsid_hpp [] = OSGSHADERCHUNKBASE_HEADER_CVSID;
00354 static Char8 cvsid_inl [] = OSGSHADERCHUNKBASE_INLINE_CVSID;
00355
00356 static Char8 cvsid_fields_hpp[] = OSGSHADERCHUNKFIELDS_HEADER_CVSID;
00357 }
00358
00359 OSG_END_NAMESPACE
00360