#include <OSGProgramChunk.h>
Inheritance diagram for osg::ProgramChunk:

General Fieldcontainer Declaration | |
| virtual osg::FieldContainerPtr | shallowCopy (void) const |
| static AttachmentPtr | create (void) |
| static AttachmentPtr | createEmpty (void) |
Public Types | |
| typedef ProgramChunkPtr | Ptr |
| enum | { ProgramFieldId = Inherited::NextFieldId, ParamValuesFieldId = ProgramFieldId + 1, ParamNamesFieldId = ParamValuesFieldId + 1, GLIdFieldId = ParamNamesFieldId + 1, NextFieldId = GLIdFieldId + 1 } |
Public Member Functions | |
Chunk Class Access | |
| *virtual const StateChunkClass * | getClass (void) const |
Sync | |
| *virtual void | changed (BitVector whichField, UInt32 origin) |
Output | |
| *virtual void | dump (UInt32 uiIndent=0, const BitVector bvFlags=0) const |
ProgamChunk Commands | |
| *bool | read (const char *file) |
| bool | read (std::istream &stream) |
| bool | addParameter (const char *name, Int16 index) |
| bool | addParameter (const char *name, Int16 index, const Vec4f &value) |
| const Vec4f & | getParameter (Int16 index) |
| const Vec4f & | getParameter (const char *name) |
| const Vec4f & | getParameter (const std::string &name) |
| bool | setParameter (Int16 index, const Vec4f &value) |
| bool | setParameter (const char *name, const Vec4f &value) |
| bool | setParameter (const std::string &name, const Vec4f &value) |
| Int16 | findParameter (const char *name) |
| Int16 | findParameter (const std::string &name) |
State Commands | |
| *virtual void | activate (DrawActionBase *action, UInt32 index=0) |
| virtual void | changeFrom (DrawActionBase *action, StateChunk *old, UInt32 index=0) |
| virtual void | deactivate (DrawActionBase *action, UInt32 index=0) |
| virtual bool | isTransparent (void) const |
Comparison | |
| *virtual Real32 | switchCost (StateChunk *chunk) |
| virtual bool | operator< (const StateChunk &other) const |
| virtual bool | operator== (const StateChunk &other) const |
| virtual bool | operator!= (const StateChunk &other) const |
FieldContainer Get | |
| *virtual FieldContainerType & | getType (void) |
| virtual const FieldContainerType & | getType (void) const |
| virtual UInt32 | getContainerSize (void) const |
Field Get | |
| *SFString * | getSFProgram (void) |
| Get the ProgramChunk::_sfProgram field. | |
| MFVec4f * | getMFParamValues (void) |
| Get the ProgramChunk::_mfParamValues field. | |
| MFString * | getMFParamNames (void) |
| Get the ProgramChunk::_mfParamNames field. | |
| std::string & | getProgram (void) |
| Get the value of the ProgramChunk::_sfProgram field. | |
| const std::string & | getProgram (void) const |
| Get the value of the ProgramChunk::_sfProgram field. | |
| Vec4f & | getParamValues (const UInt32 index) |
| Get the value of the index element the ProgramChunk::_mfParamValues field. | |
| MFVec4f & | getParamValues (void) |
| Get the ProgramChunk::_mfParamValues field. | |
| const MFVec4f & | getParamValues (void) const |
| Get the ProgramChunk::_mfParamValues field. | |
| std::string & | getParamNames (const UInt32 index) |
| Get the value of the index element the ProgramChunk::_mfParamNames field. | |
| MFString & | getParamNames (void) |
| Get the ProgramChunk::_mfParamNames field. | |
| const MFString & | getParamNames (void) const |
| Get the ProgramChunk::_mfParamNames field. | |
Field Set | |
| *void | setProgram (const std::string &value) |
| Set the value of the ProgramChunk::_sfProgram field. | |
Binary Access | |
| *virtual UInt32 | getBinSize (const BitVector &whichField) |
| virtual void | copyToBin (BinaryDataHandler &pMem, const BitVector &whichField) |
| virtual void | copyFromBin (BinaryDataHandler &pMem, const BitVector &whichField) |
Chunk Class Access | |
| *UInt32 | getClassId (void) const |
Parents | |
| *MFFieldContainerPtr & | getParents (void) |
| const MFFieldContainerPtr & | getParents (void) const |
| MFFieldContainerPtr * | getMFParents (void) |
| void | addParent (FieldContainerPtr parent) |
| void | subParent (FieldContainerPtr parent) |
| Int32 | findParent (FieldContainerPtr parent) |
Parents | |
| *SFBool & | getInternal (void) |
| const SFBool & | getInternal (void) const |
| SFBool * | getSFInternal (void) |
| void | setInternal (bool bVal) |
Static Public Member Functions | |
Static Chunk Class Access | |
| *static UInt32 | getStaticClassId (void) |
| static const StateChunkClass * | getStaticClass (void) |
Class Get | |
| *static FieldContainerType & | getClassType (void) |
| access the type of the class | |
| static UInt32 | getClassTypeId (void) |
| access the numerical type of the class | |
Static Public Attributes | |
| static const osg::BitVector | ProgramFieldMask |
| static const osg::BitVector | ParamValuesFieldMask |
| static const osg::BitVector | ParamNamesFieldMask |
| static const osg::BitVector | GLIdFieldMask |
| static const osg::BitVector | MTInfluenceMask |
| static const BitVector | InternalFieldMask = (1 << Attachment::InternalFieldId) |
| static const BitVector | ParentsFieldMask = (1 << Attachment::ParentsFieldId) |
| static const BitVector | NextFieldMask |
Protected Member Functions | |
Init | |
| *void | onCreate (const ProgramChunk *source=NULL) |
Constructors | |
| * | ProgramChunk (void) |
| ProgramChunk (const ProgramChunk &source) | |
Destructors | |
| *virtual | ~ProgramChunk (void) |
Program-Specific Methods | |
| *virtual UInt32 | getExtension (void) const |
| virtual GLenum | getTarget (void) const |
| virtual const char * | getTargetName (void) const |
| void | printCompileError (Window *win, UInt32 idstatus) |
GL | |
| *void | handleGL (Window *win, UInt32 id, GLenum target, UInt32 extension) |
Field Get | |
| *SFUInt32 * | getSFGLId (void) |
| Get the ProgramChunk::_sfGLId field. | |
| UInt32 & | getGLId (void) |
| Get the value of the ProgramChunk::_sfGLId field. | |
| const UInt32 & | getGLId (void) const |
| Get the value of the ProgramChunk::_sfGLId field. | |
Field Set | |
| *void | setGLId (const UInt32 &value) |
| Set the value of the ProgramChunk::_sfGLId field. | |
Sync | |
| *void | executeSyncImpl (ProgramChunkBase *pOther, const BitVector &whichField) |
| virtual void | executeSync (FieldContainer &other, const BitVector &whichField) |
Sync | |
| *void | executeSyncImpl (StateChunkBase *pOther, const BitVector &whichField) |
Sync | |
| void | executeSyncImpl (Attachment *pOther, const BitVector &whichField) |
MT Destruction | |
| *virtual void | onDestroy (void) |
Protected Attributes | |
Fields | |
| *SFString | _sfProgram |
| MFVec4f | _mfParamValues |
| MFString | _mfParamNames |
| SFUInt32 | _sfGLId |
Fields | |
| *SFBool | _sfInternal |
| MFFieldContainerPtr | _parents |
Private Types | |
| typedef ProgramChunkBase | Inherited |
Private Member Functions | |
| void | operator= (const ProgramChunk &source) |
Static Private Member Functions | |
| static void | initMethod (void) |
Static Private Attributes | |
| static StateChunkClass | _class |
OpenGL Extension Handling | |
| *static UInt32 | _funcProgramString |
| static UInt32 | _funcBindProgram |
| static UInt32 | _funcDeletePrograms |
| static UInt32 | _funcProgramLocalParameter4fv |
| static UInt32 | _funcGetProgramiv |
Friends | |
| class | FieldContainer |
| class | ProgramChunkBase |
Definition at line 57 of file OSGProgramChunk.h.
|
|
Reimplemented from osg::ProgramChunkBase. Reimplemented in osg::FatBorderChunk, osg::FatBorderChunkBase, osg::FragmentProgramChunk, osg::FragmentProgramChunkBase, osg::VertexProgramChunk, and osg::VertexProgramChunkBase. Definition at line 61 of file OSGProgramChunk.h. |
|
|
Reimplemented from osg::StateChunkBase. Reimplemented in osg::FatBorderChunkBase, osg::FragmentProgramChunkBase, and osg::VertexProgramChunkBase. Definition at line 93 of file OSGProgramChunkBase.h. |
|
|
Reimplemented from osg::Attachment. Definition at line 95 of file OSGProgramChunkBase.h. 00096 { 00097 ProgramFieldId = Inherited::NextFieldId, 00098 ParamValuesFieldId = ProgramFieldId + 1, 00099 ParamNamesFieldId = ParamValuesFieldId + 1, 00100 GLIdFieldId = ParamNamesFieldId + 1, 00101 NextFieldId = GLIdFieldId + 1 00102 };
|
|
|
|
Definition at line 129 of file OSGProgramChunk.cpp. 00129 : 00130 Inherited(source) 00131 { 00132 }
|
|
|
Definition at line 134 of file OSGProgramChunk.cpp. References osg::Window::destroyGLObject(), and osg::ProgramChunkBase::getGLId(). 00135 { 00136 if(getGLId() > 0) 00137 Window::destroyGLObject(getGLId(), 1); 00138 }
|
|
|
Reimplemented from osg::StateChunk. Reimplemented in osg::FragmentProgramChunk, and osg::VertexProgramChunk. Definition at line 149 of file OSGProgramChunk.cpp. References _class. 00150 { 00151 return &_class; 00152 }
|
|
|
Reimplemented from osg::StateChunk. Reimplemented in osg::FragmentProgramChunk, and osg::VertexProgramChunk. Definition at line 46 of file OSGProgramChunk.inl. References osg::StateChunkClass::getId(), and getStaticClass(). 00047 { 00048 return getStaticClass()->getId(); 00049 }
|
|
|
Reimplemented from osg::StateChunk. Reimplemented in osg::FragmentProgramChunk, and osg::VertexProgramChunk. Definition at line 52 of file OSGProgramChunk.inl. References _class. Referenced by getStaticClassId(). 00053 { 00054 return &ProgramChunk::_class; 00055 }
|
|
||||||||||||
|
Reimplemented from osg::StateChunk. Reimplemented in osg::FatBorderChunk, osg::FragmentProgramChunk, and osg::VertexProgramChunk. Definition at line 156 of file OSGProgramChunk.cpp. References osg::StateChunk::changed(), osg::ProgramChunkBase::getGLId(), osg::ProgramChunkBase::ParamValuesFieldMask, osg::ProgramChunkBase::ProgramFieldMask, osg::Window::refreshGLObject(), and osg::Window::reinitializeGLObject(). Referenced by osg::VertexProgramChunk::changed(), and osg::FragmentProgramChunk::changed(). 00157 { 00158 Inherited::changed(whichField, origin); 00159 00160 if(whichField & ProgramFieldMask) 00161 { 00162 Window::reinitializeGLObject(getGLId()); 00163 } 00164 00165 if(whichField & ParamValuesFieldMask) 00166 { 00167 Window::refreshGLObject(getGLId()); 00168 } 00169 }
|
|
||||||||||||
|
Reimplemented from osg::StateChunk. Reimplemented in osg::FatBorderChunk, osg::FragmentProgramChunk, and osg::VertexProgramChunk. Definition at line 173 of file OSGProgramChunk.cpp. References SLOG. 00175 { 00176 SLOG << "Dump ProgramChunk NI" << std::endl; 00177 }
|
|
|
Read the program string from the given file Definition at line 183 of file OSGProgramChunk.cpp. References FWARNING. 00184 { 00185 std::ifstream s(file); 00186 00187 if(s.good()) 00188 { 00189 return read(s); 00190 } 00191 else 00192 { 00193 FWARNING(("ProgramChunk::read: couldn't open '%s' for reading!\n", 00194 file)); 00195 return false; 00196 } 00197 }
|
|
|
Read the program string from the given stream Definition at line 201 of file OSGProgramChunk.cpp. References BUFSIZE, FWARNING, and osg::ProgramChunkBase::getProgram(). 00202 { 00203 #define BUFSIZE 200 00204 00205 getProgram().erase(); 00206 char buf[BUFSIZE]; 00207 00208 if(!stream.good()) 00209 { 00210 FWARNING(("ProgramChunk::read: stream is not good!\n")); 00211 return false; 00212 00213 } 00214 00215 do 00216 { 00217 stream.read(buf, BUFSIZE); 00218 getProgram().append(buf, stream.gcount()); 00219 } 00220 while(!stream.eof()); 00221 00222 return true; 00223 }
|
|
||||||||||||
|
Add a named parameter Definition at line 227 of file OSGProgramChunk.cpp. References osg::ProgramChunkBase::getParamNames(), osg::MField< FieldTypeT, fieldNameSpace >::resize(), and osg::MField< FieldTypeT, fieldNameSpace >::size(). Referenced by addParameter(). 00229 { 00230 if(index < 0) 00231 return true; 00232 00233 if(getParamNames().size() <= UInt16(index)) 00234 { 00235 getParamNames().resize(index + 1); 00236 } 00237 getParamNames()[index] = name; 00238 return false; 00239 }
|
|
||||||||||||||||
|
Concvenience function to add a new parameter and directly set its value. Definition at line 63 of file OSGProgramChunk.inl. References addParameter(), and setParameter(). 00066 { 00067 addParameter(name, index); 00068 return setParameter(index, value); 00069 }
|
|
|
Read the program string from the given file Definition at line 241 of file OSGProgramChunk.cpp. References osg::ProgramChunkBase::getParamValues(), and osg::MField< FieldTypeT, fieldNameSpace >::size(). Referenced by getParameter(). 00242 { 00243 static const Vec4f bad(-1e10,-1e10,-1e10); 00244 00245 if(index < 0) 00246 return bad; 00247 00248 if(getParamValues().size() <= UInt16(index)) 00249 { 00250 return getParamValues()[index]; 00251 } 00252 00253 return bad; 00254 }
|
|
|
Read the program string from the given file Definition at line 72 of file OSGProgramChunk.inl. References findParameter(), and getParameter(). 00073 { 00074 return getParameter(findParameter(name)); 00075 }
|
|
|
Read the program string from the given file Definition at line 78 of file OSGProgramChunk.inl. References findParameter(), and getParameter(). 00079 { 00080 return getParameter(findParameter(name.c_str())); 00081 }
|
|
||||||||||||
|
Set parameter value, create it if not set yet. Definition at line 258 of file OSGProgramChunk.cpp. References osg::ProgramChunkBase::getParamValues(), osg::MField< FieldTypeT, fieldNameSpace >::resize(), and osg::MField< FieldTypeT, fieldNameSpace >::size(). Referenced by addParameter(), and setParameter(). 00259 { 00260 if(index < 0) 00261 return true; 00262 00263 if(getParamValues().size() <= UInt16(index)) 00264 { 00265 getParamValues().resize(index + 1); 00266 } 00267 getParamValues()[index] = value; 00268 return false; 00269 }
|
|
||||||||||||
|
Read the program string from the given file Definition at line 84 of file OSGProgramChunk.inl. References findParameter(), and setParameter(). 00085 { 00086 return setParameter(findParameter(name), value); 00087 }
|
|
||||||||||||
|
Read the program string from the given file Definition at line 90 of file OSGProgramChunk.inl. References findParameter(), and setParameter(). 00091 { 00092 return setParameter(findParameter(name.c_str()), value); 00093 }
|
|
|
Read the program string from the given file Definition at line 96 of file OSGProgramChunk.inl. Referenced by getParameter(), and setParameter(). 00097 { 00098 return findParameter(std::string(name)); 00099 }
|
|
|
Find the index for a named parameter, return -1 if not found. Definition at line 273 of file OSGProgramChunk.cpp. References osg::MField< FieldTypeT, fieldNameSpace >::begin(), osg::MField< FieldTypeT, fieldNameSpace >::end(), and osg::ProgramChunkBase::getParamNames(). 00274 { 00275 MField<std::string>::iterator it; 00276 00277 it = std::find(getParamNames().begin(), getParamNames().end(), name); 00278 00279 if(it == getParamNames().end()) 00280 return -1; 00281 00282 return it - getParamNames().begin(); 00283 }
|
|
||||||||||||
|
Activate the chunk, i.e. set the OpenGl state covered by the chunk which is different from the default state to the given state. Reimplemented from osg::StateChunk. Definition at line 450 of file OSGProgramChunk.cpp. References _funcBindProgram, getExtension(), osg::Window::getFunction(), osg::ProgramChunkBase::getGLId(), osg::ProgramChunkBase::getProgram(), getTarget(), osg::DrawActionBase::getWindow(), GLenum, glErr, GLuint(), osg::Window::hasExtension(), OSG_APIENTRY, and osg::Window::validateGLObject(). 00451 { 00452 // get the program-type specifics from the derived chunks 00453 GLenum target = getTarget(); 00454 UInt32 extension = getExtension(); 00455 00456 if(!action->getWindow()->hasExtension(extension)) 00457 { 00458 return; 00459 } 00460 00461 if(getProgram().empty()) 00462 return; 00463 00464 action->getWindow()->validateGLObject(getGLId()); 00465 00466 // get "glBindProgramARB" function pointer 00467 void (OSG_APIENTRY* bindProgram)(GLenum target, GLuint prog) = 00468 (void (OSG_APIENTRY*)(GLenum target, GLuint prog)) 00469 action->getWindow()->getFunction(_funcBindProgram); 00470 00471 glErr("ProgramChunk::activate: bindProgram precheck"); 00472 00473 glEnable(target); 00474 00475 glErr("ProgramChunk::activate: enable postcheck"); 00476 00477 bindProgram(target, getGLId()); 00478 00479 glErr("ProgramChunk::activate: bindProgram postcheck"); 00480 }
|
|
||||||||||||||||
|
Change from an old chunk of the same type to this chunk. Note that in general no type checking is done, make sure to use this on a legal combination of chunks! Reimplemented from osg::StateChunk. Definition at line 482 of file OSGProgramChunk.cpp. References _funcBindProgram, FWARNING, getExtension(), osg::Window::getFunction(), osg::ProgramChunkBase::getGLId(), osg::ProgramChunkBase::getProgram(), getTarget(), osg::DrawActionBase::getWindow(), GLenum, glErr, GLuint(), osg::Window::hasExtension(), OSG_APIENTRY, and osg::Window::validateGLObject(). 00485 { 00486 ProgramChunk * old = dynamic_cast<ProgramChunk*>(old_chunk); 00487 00488 if(old == NULL) 00489 { 00490 FWARNING(( "ProgramChunk::changeFrom: caught non-ProgramChunk!\n")); 00491 return; 00492 } 00493 00494 // get the program-type specifics from the derived chunks 00495 GLenum target = getTarget(); 00496 UInt32 extension = getExtension(); 00497 00498 if(!action->getWindow()->hasExtension(extension)) 00499 return; 00500 00501 if(getProgram().empty()) 00502 { 00503 if(old->getProgram().empty()) 00504 return; 00505 00506 glDisable(target); 00507 } 00508 00509 action->getWindow()->validateGLObject(getGLId()); 00510 00511 // get "glBindProgramARB" function pointer 00512 void (OSG_APIENTRY* bindProgram)(GLenum target, GLuint prog) = 00513 (void (OSG_APIENTRY*)(GLenum target, GLuint prog)) 00514 action->getWindow()->getFunction(_funcBindProgram); 00515 00516 glErr("ProgramChunk::changeFrom: bindProgram precheck"); 00517 00518 if(old->getProgram().empty()) 00519 glEnable(target); 00520 00521 glErr("ProgramChunk::changeFrom: enable postcheck"); 00522 00523 bindProgram(target, getGLId()); 00524 00525 glErr("ProgramChunk::changeFrom: bindProgram postcheck"); 00526 }
|
|
||||||||||||
|
Deactivate the chunk, i.e. set the OpenGl state covered by the chunk which is different from the default state to the default state. Reimplemented from osg::StateChunk. Definition at line 528 of file OSGProgramChunk.cpp. References _funcBindProgram, getExtension(), osg::Window::getFunction(), osg::ProgramChunkBase::getGLId(), osg::ProgramChunkBase::getProgram(), getTarget(), osg::DrawActionBase::getWindow(), GLenum, glErr, GLuint(), osg::Window::hasExtension(), and OSG_APIENTRY. 00529 { 00530 // get the program-type specifics from the derived chunks 00531 GLenum target = getTarget(); 00532 UInt32 extension = getExtension(); 00533 00534 if(!action->getWindow()->hasExtension(extension)) 00535 { 00536 return; 00537 } 00538 00539 if(getProgram().empty()) 00540 { 00541 return; 00542 } 00543 00544 // get "glBindProgramARB" function pointer 00545 void (OSG_APIENTRY* bindProgram)(GLenum target, GLuint prog) = 00546 (void (OSG_APIENTRY*)(GLenum target, GLuint prog)) 00547 action->getWindow()->getFunction(_funcBindProgram); 00548 00549 00550 glErr("ProgramChunk::deactivate: bindProgram precheck"); 00551 00552 bindProgram(target, getGLId()); 00553 00554 glErr("ProgramChunk::deactivate: bindProgram postcheck"); 00555 00556 glDisable(target); 00557 00558 glErr("ProgramChunk::deactivate: disable postcheck"); 00559 }
|
|
|
Check if the chunk is transparent, i.e. needs to be rendered after the opaque objects. Reimplemented from osg::StateChunk. Definition at line 591 of file OSGProgramChunk.cpp.
|
|
|
Calculate how expensive it is to switch from one instance of the chunk class to another. In most cases not implemented yet, will return 0. Reimplemented from osg::StateChunk. Definition at line 596 of file OSGProgramChunk.cpp.
|
|
|
Calculate how expensive it is to switch from one instance of the chunk class to another. In most cases not implemented yet, will return 0. Reimplemented from osg::StateChunk. Definition at line 601 of file OSGProgramChunk.cpp. |