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_USING_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::MTInfluenceMask =
00074 (Inherited::MTInfluenceMask) |
00075 (static_cast<BitVector>(0x0) << Inherited::NextFieldId);
00076
00077
00078
00079
00087
00088
00089 FieldDescription *ShaderChunkBase::_desc[] =
00090 {
00091 new FieldDescription(SFString::getClassType(),
00092 "vertexProgram",
00093 VertexProgramFieldId, VertexProgramFieldMask,
00094 false,
00095 (FieldAccessMethod) &ShaderChunkBase::getSFVertexProgram),
00096 new FieldDescription(SFString::getClassType(),
00097 "fragmentProgram",
00098 FragmentProgramFieldId, FragmentProgramFieldMask,
00099 false,
00100 (FieldAccessMethod) &ShaderChunkBase::getSFFragmentProgram)
00101 };
00102
00103
00104 FieldContainerType ShaderChunkBase::_type(
00105 "ShaderChunk",
00106 "ShaderParameterChunk",
00107 NULL,
00108 NULL,
00109 ShaderChunk::initMethod,
00110 _desc,
00111 sizeof(_desc));
00112
00113
00114
00115
00116
00117 FieldContainerType &ShaderChunkBase::getType(void)
00118 {
00119 return _type;
00120 }
00121
00122 const FieldContainerType &ShaderChunkBase::getType(void) const
00123 {
00124 return _type;
00125 }
00126
00127
00128 UInt32 ShaderChunkBase::getContainerSize(void) const
00129 {
00130 return sizeof(ShaderChunk);
00131 }
00132
00133
00134 #if !defined(OSG_FIXED_MFIELDSYNC)
00135 void ShaderChunkBase::executeSync( FieldContainer &other,
00136 const BitVector &whichField)
00137 {
00138 this->executeSyncImpl((ShaderChunkBase *) &other, whichField);
00139 }
00140 #else
00141 void ShaderChunkBase::executeSync( FieldContainer &other,
00142 const BitVector &whichField, const SyncInfo &sInfo )
00143 {
00144 this->executeSyncImpl((ShaderChunkBase *) &other, whichField, sInfo);
00145 }
00146 void ShaderChunkBase::execBeginEdit(const BitVector &whichField,
00147 UInt32 uiAspect,
00148 UInt32 uiContainerSize)
00149 {
00150 this->execBeginEditImpl(whichField, uiAspect, uiContainerSize);
00151 }
00152
00153 void ShaderChunkBase::onDestroyAspect(UInt32 uiId, UInt32 uiAspect)
00154 {
00155 Inherited::onDestroyAspect(uiId, uiAspect);
00156
00157 }
00158 #endif
00159
00160
00161
00162 #ifdef OSG_WIN32_ICL
00163 #pragma warning (disable : 383)
00164 #endif
00165
00166 ShaderChunkBase::ShaderChunkBase(void) :
00167 _sfVertexProgram (),
00168 _sfFragmentProgram (),
00169 Inherited()
00170 {
00171 }
00172
00173 #ifdef OSG_WIN32_ICL
00174 #pragma warning (default : 383)
00175 #endif
00176
00177 ShaderChunkBase::ShaderChunkBase(const ShaderChunkBase &source) :
00178 _sfVertexProgram (source._sfVertexProgram ),
00179 _sfFragmentProgram (source._sfFragmentProgram ),
00180 Inherited (source)
00181 {
00182 }
00183
00184
00185
00186 ShaderChunkBase::~ShaderChunkBase(void)
00187 {
00188 }
00189
00190
00191
00192 UInt32 ShaderChunkBase::getBinSize(const BitVector &whichField)
00193 {
00194 UInt32 returnValue = Inherited::getBinSize(whichField);
00195
00196 if(FieldBits::NoField != (VertexProgramFieldMask & whichField))
00197 {
00198 returnValue += _sfVertexProgram.getBinSize();
00199 }
00200
00201 if(FieldBits::NoField != (FragmentProgramFieldMask & whichField))
00202 {
00203 returnValue += _sfFragmentProgram.getBinSize();
00204 }
00205
00206
00207 return returnValue;
00208 }
00209
00210 void ShaderChunkBase::copyToBin( BinaryDataHandler &pMem,
00211 const BitVector &whichField)
00212 {
00213 Inherited::copyToBin(pMem, whichField);
00214
00215 if(FieldBits::NoField != (VertexProgramFieldMask & whichField))
00216 {
00217 _sfVertexProgram.copyToBin(pMem);
00218 }
00219
00220 if(FieldBits::NoField != (FragmentProgramFieldMask & whichField))
00221 {
00222 _sfFragmentProgram.copyToBin(pMem);
00223 }
00224
00225
00226 }
00227
00228 void ShaderChunkBase::copyFromBin( BinaryDataHandler &pMem,
00229 const BitVector &whichField)
00230 {
00231 Inherited::copyFromBin(pMem, whichField);
00232
00233 if(FieldBits::NoField != (VertexProgramFieldMask & whichField))
00234 {
00235 _sfVertexProgram.copyFromBin(pMem);
00236 }
00237
00238 if(FieldBits::NoField != (FragmentProgramFieldMask & whichField))
00239 {
00240 _sfFragmentProgram.copyFromBin(pMem);
00241 }
00242
00243
00244 }
00245
00246 #if !defined(OSG_FIXED_MFIELDSYNC)
00247 void ShaderChunkBase::executeSyncImpl( ShaderChunkBase *pOther,
00248 const BitVector &whichField)
00249 {
00250
00251 Inherited::executeSyncImpl(pOther, whichField);
00252
00253 if(FieldBits::NoField != (VertexProgramFieldMask & whichField))
00254 _sfVertexProgram.syncWith(pOther->_sfVertexProgram);
00255
00256 if(FieldBits::NoField != (FragmentProgramFieldMask & whichField))
00257 _sfFragmentProgram.syncWith(pOther->_sfFragmentProgram);
00258
00259
00260 }
00261 #else
00262 void ShaderChunkBase::executeSyncImpl( ShaderChunkBase *pOther,
00263 const BitVector &whichField,
00264 const SyncInfo &sInfo )
00265 {
00266
00267 Inherited::executeSyncImpl(pOther, whichField, sInfo);
00268
00269 if(FieldBits::NoField != (VertexProgramFieldMask & whichField))
00270 _sfVertexProgram.syncWith(pOther->_sfVertexProgram);
00271
00272 if(FieldBits::NoField != (FragmentProgramFieldMask & whichField))
00273 _sfFragmentProgram.syncWith(pOther->_sfFragmentProgram);
00274
00275
00276
00277 }
00278
00279 void ShaderChunkBase::execBeginEditImpl (const BitVector &whichField,
00280 UInt32 uiAspect,
00281 UInt32 uiContainerSize)
00282 {
00283 Inherited::execBeginEditImpl(whichField, uiAspect, uiContainerSize);
00284
00285 }
00286 #endif
00287
00288
00289
00290 #include <OSGSFieldTypeDef.inl>
00291 #include <OSGMFieldTypeDef.inl>
00292
00293 OSG_BEGIN_NAMESPACE
00294
00295 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
00296 DataType FieldDataTraits<ShaderChunkPtr>::_type("ShaderChunkPtr", "ShaderParameterChunkPtr");
00297 #endif
00298
00299 OSG_DLLEXPORT_SFIELD_DEF1(ShaderChunkPtr, OSG_SYSTEMLIB_DLLTMPLMAPPING);
00300 OSG_DLLEXPORT_MFIELD_DEF1(ShaderChunkPtr, OSG_SYSTEMLIB_DLLTMPLMAPPING);
00301
00302 OSG_END_NAMESPACE
00303
00304
00305
00306
00307
00308 #ifdef OSG_SGI_CC
00309 #pragma set woff 1174
00310 #endif
00311
00312 #ifdef OSG_LINUX_ICC
00313 #pragma warning( disable : 177 )
00314 #endif
00315
00316 namespace
00317 {
00318 static Char8 cvsid_cpp [] = "@(#)$Id: OSGShaderChunkBase.cpp,v 1.6 2005/07/20 00:08:58 vossg Exp $";
00319 static Char8 cvsid_hpp [] = OSGSHADERCHUNKBASE_HEADER_CVSID;
00320 static Char8 cvsid_inl [] = OSGSHADERCHUNKBASE_INLINE_CVSID;
00321
00322 static Char8 cvsid_fields_hpp[] = OSGSHADERCHUNKFIELDS_HEADER_CVSID;
00323 }
00324