OpenSceneGraph  3.0.1
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
osg::Program::PerContextProgram Class Reference

PerContextProgram (PCP) is an OSG-internal encapsulation of glPrograms per-GL context. More...

Inheritance diagram for osg::Program::PerContextProgram:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 PerContextProgram (const Program *program, unsigned int contextID)
GLuint getHandle () const
void requestLink ()
void linkProgram (osg::State &state)
bool validateProgram ()
bool needsLink () const
bool isLinked () const
bool getInfoLog (std::string &infoLog) const
bool loadedBinary () const
 Was glProgramBinary called successfully?
ProgramBinarycompileProgramBinary (osg::State &state)
 Compile a program binary.
void useProgram () const
void resetAppliedUniforms () const
void apply (const Uniform &uniform) const
const ActiveUniformMapgetActiveUniforms () const
const ActiveVarInfoMapgetActiveAttribs () const
const UniformBlockMapgetUniformBlocks () 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::vector
< UniformModifiedCountPair
LastAppliedUniformList
typedef std::vector< ref_ptr
< Shader > > 
ShaderList

Protected Member Functions

 ~PerContextProgram ()

Protected Attributes

const Program_program
 Pointer to our parent Program.
osg::ref_ptr< GL2Extensions_extensions
 Pointer to this context's extension functions.
GLuint _glProgramHandle
 Handle to the actual OpenGL glProgram.
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
ActiveUniformMap _uniformInfoMap
ActiveVarInfoMap _attribInfoMap
UniformBlockMap _uniformBlockMap
LastAppliedUniformList _lastAppliedUniformList
ShaderList _shadersToDetach
ShaderList _shadersToAttach

Detailed Description

PerContextProgram (PCP) is an OSG-internal encapsulation of glPrograms per-GL context.


Member Typedef Documentation

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]

Constructor & Destructor Documentation

osg::Program::PerContextProgram::PerContextProgram ( const Program program,
unsigned int  contextID 
)
osg::Program::PerContextProgram::~PerContextProgram ( ) [protected]

Member Function Documentation

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]
ProgramBinary* osg::Program::PerContextProgram::compileProgramBinary ( osg::State state)

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]
GLuint osg::Program::PerContextProgram::getHandle ( ) const [inline]
bool osg::Program::PerContextProgram::getInfoLog ( std::string &  infoLog) const
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 getUniformLocation(), and osg::Uniform::getNameID().

Referenced by getUniformLocation().

bool osg::Program::PerContextProgram::isLinked ( ) const [inline]
void osg::Program::PerContextProgram::linkProgram ( osg::State state)
bool osg::Program::PerContextProgram::loadedBinary ( ) const [inline]

Was glProgramBinary called successfully?

bool osg::Program::PerContextProgram::needsLink ( ) const [inline]
void osg::Program::PerContextProgram::requestLink ( )
void osg::Program::PerContextProgram::resetAppliedUniforms ( ) const [inline]
void osg::Program::PerContextProgram::useProgram ( ) const
bool osg::Program::PerContextProgram::validateProgram ( )

Member Data Documentation

const unsigned int osg::Program::PerContextProgram::_contextID [protected]

Pointer to this context's extension functions.

Handle to the actual OpenGL glProgram.

Is our glProgram successfully linked?

Was glProgramBinary called successfully?

Does our glProgram need to be linked?

Pointer to our parent Program.


The documentation for this class was generated from the following file:

osg logo
Generated at Mon Oct 3 2011 12:39:43 for the OpenSceneGraph by doxygen 1.7.5.