OpenSceneGraph
3.4.0
|
PerContextProgram (PCP) is an OSG-internal encapsulation of glPrograms per-GL context. More...
Public Member Functions | |
PerContextProgram (const Program *program, unsigned int contextID, GLuint programHandle=0) | |
Use "0" as programHandle to let the PeContextProgram execute "glCreateProgram"and "glDeleteProgram". | |
GLuint | getHandle () const |
const osg::Program * | getProgram () const |
void | setDefineString (const std::string &defStr) |
const std::string & | getDefineString () const |
void | requestLink () |
virtual void | linkProgram (osg::State &state) |
virtual bool | validateProgram () |
bool | needsLink () const |
bool | isLinked () const |
virtual bool | getInfoLog (std::string &infoLog) const |
bool | loadedBinary () const |
Was glProgramBinary called successfully? | |
virtual ProgramBinary * | compileProgramBinary (osg::State &state) |
Compile a program binary. | |
virtual void | useProgram () const |
void | resetAppliedUniforms () const |
void | apply (const Uniform &uniform) const |
const ActiveUniformMap & | getActiveUniforms () const |
const ActiveVarInfoMap & | getActiveAttribs () const |
const UniformBlockMap & | getUniformBlocks () const |
GLint | getUniformLocation (unsigned int uniformNameID) const |
GLint | getUniformLocation (const std::string &uniformName) const |
Alternative version of getUniformLocation( unsigned int uniformNameID ) retrofited into OSG for backward compatibility with osgCal, after uniform ids were refactored from std::strings to GLints in OSG version 2.9.10. | |
GLint | getAttribLocation (const std::string &name) const |
void | addShaderToAttach (Shader *shader) |
void | addShaderToDetach (Shader *shader) |
Protected Types | |
typedef std::pair < osg::ref_ptr< const osg::Uniform >, unsigned int > | UniformModifiedCountPair |
typedef std::map< unsigned int, UniformModifiedCountPair > | LastAppliedUniformList |
typedef std::vector< ref_ptr < Shader > > | ShaderList |
Protected Member Functions | |
virtual | ~PerContextProgram () |
Protected Attributes | |
const Program * | _program |
Pointer to our parent Program. | |
osg::ref_ptr< GLExtensions > | _extensions |
Pointer to this context's extension functions. | |
GLuint | _glProgramHandle |
Handle to the actual OpenGL glProgram. | |
std::string | _defineStr |
Define string passed on to Shaders to help configure them. | |
bool | _needsLink |
Does our glProgram need to be linked? | |
bool | _isLinked |
Is our glProgram successfully linked? | |
bool | _loadedBinary |
Was glProgramBinary called successfully? | |
const unsigned int | _contextID |
bool | _ownsProgramHandle |
Does the glProgram handle belongs to this class? | |
ActiveUniformMap | _uniformInfoMap |
ActiveVarInfoMap | _attribInfoMap |
UniformBlockMap | _uniformBlockMap |
LastAppliedUniformList | _lastAppliedUniformList |
ShaderList | _shadersToDetach |
ShaderList | _shadersToAttach |
PerContextProgram (PCP) is an OSG-internal encapsulation of glPrograms per-GL context.
typedef std::map<unsigned int, UniformModifiedCountPair> osg::Program::PerContextProgram::LastAppliedUniformList [protected] |
typedef std::vector< ref_ptr<Shader> > osg::Program::PerContextProgram::ShaderList [protected] |
typedef std::pair<osg::ref_ptr<const osg::Uniform>, unsigned int> osg::Program::PerContextProgram::UniformModifiedCountPair [protected] |
osg::Program::PerContextProgram::PerContextProgram | ( | const Program * | program, |
unsigned int | contextID, | ||
GLuint | programHandle = 0 |
||
) |
Use "0" as programHandle to let the PeContextProgram execute "glCreateProgram"and "glDeleteProgram".
virtual osg::Program::PerContextProgram::~PerContextProgram | ( | ) | [protected, virtual] |
void osg::Program::PerContextProgram::addShaderToAttach | ( | Shader * | shader | ) | [inline] |
void osg::Program::PerContextProgram::addShaderToDetach | ( | Shader * | shader | ) | [inline] |
void osg::Program::PerContextProgram::apply | ( | const Uniform & | uniform | ) | const [inline] |
References osg::Uniform::apply(), osg::Uniform::get(), osg::Uniform::getModifiedCount(), and osg::Uniform::getNameID().
Referenced by osg::State::applyUniformList(), and osg::State::applyUniformMap().
virtual ProgramBinary* osg::Program::PerContextProgram::compileProgramBinary | ( | osg::State & | state | ) | [virtual] |
Compile a program binary.
For this to work setProgramBinary must have been called on the osg::Program with an empty ProgramBinary prior to compileGLObjects being called. compileProgramBinary should be called after the program has been "exercised" by rendering with it. The ProgramBinary can then be saved to disk for faster subsequent compiling.
const ActiveVarInfoMap& osg::Program::PerContextProgram::getActiveAttribs | ( | ) | const [inline] |
const ActiveUniformMap& osg::Program::PerContextProgram::getActiveUniforms | ( | ) | const [inline] |
GLint osg::Program::PerContextProgram::getAttribLocation | ( | const std::string & | name | ) | const [inline] |
const std::string& osg::Program::PerContextProgram::getDefineString | ( | ) | const [inline] |
GLuint osg::Program::PerContextProgram::getHandle | ( | ) | const [inline] |
virtual bool osg::Program::PerContextProgram::getInfoLog | ( | std::string & | infoLog | ) | const [virtual] |
const osg::Program* osg::Program::PerContextProgram::getProgram | ( | ) | const [inline] |
const UniformBlockMap& osg::Program::PerContextProgram::getUniformBlocks | ( | ) | const [inline] |
GLint osg::Program::PerContextProgram::getUniformLocation | ( | unsigned int | uniformNameID | ) | const [inline] |
GLint osg::Program::PerContextProgram::getUniformLocation | ( | const std::string & | uniformName | ) | const [inline] |
Alternative version of getUniformLocation( unsigned int uniformNameID ) retrofited into OSG for backward compatibility with osgCal, after uniform ids were refactored from std::strings to GLints in OSG version 2.9.10.
Drawbacks: This method is not particularly fast. It has to access mutexed static map of uniform ids. So don't overuse it or your app performance will suffer.
References osg::Uniform::getNameID(), and getUniformLocation().
Referenced by getUniformLocation().
bool osg::Program::PerContextProgram::isLinked | ( | ) | const [inline] |
virtual void osg::Program::PerContextProgram::linkProgram | ( | osg::State & | state | ) | [virtual] |
bool osg::Program::PerContextProgram::loadedBinary | ( | ) | const [inline] |
Was glProgramBinary called successfully?
bool osg::Program::PerContextProgram::needsLink | ( | ) | const [inline] |
void osg::Program::PerContextProgram::resetAppliedUniforms | ( | ) | const [inline] |
void osg::Program::PerContextProgram::setDefineString | ( | const std::string & | defStr | ) | [inline] |
virtual void osg::Program::PerContextProgram::useProgram | ( | ) | const [virtual] |
virtual bool osg::Program::PerContextProgram::validateProgram | ( | ) | [virtual] |
const unsigned int osg::Program::PerContextProgram::_contextID [protected] |
std::string osg::Program::PerContextProgram::_defineStr [protected] |
Define string passed on to Shaders to help configure them.
Pointer to this context's extension functions.
GLuint osg::Program::PerContextProgram::_glProgramHandle [protected] |
Handle to the actual OpenGL glProgram.
bool osg::Program::PerContextProgram::_isLinked [protected] |
Is our glProgram successfully linked?
LastAppliedUniformList osg::Program::PerContextProgram::_lastAppliedUniformList [mutable, protected] |
bool osg::Program::PerContextProgram::_loadedBinary [protected] |
Was glProgramBinary called successfully?
bool osg::Program::PerContextProgram::_needsLink [protected] |
Does our glProgram need to be linked?
bool osg::Program::PerContextProgram::_ownsProgramHandle [protected] |
Does the glProgram handle belongs to this class?
const Program* osg::Program::PerContextProgram::_program [protected] |
Pointer to our parent Program.
![]() | Generated at Tue Dec 8 2015 00:16:43 for the OpenSceneGraph by doxygen 1.7.6.1. |