OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
osg::Program::PerContextProgram Class Reference

#include <Program.h>

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

Public Member Functions

 PerContextProgram (const Program *program, unsigned int contextID, GLuint programHandle=0)
 
GLuint getHandle () const
 
const osg::ProgramgetProgram () 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
 
virtual ProgramBinarycompileProgramBinary (osg::State &state)
 
virtual 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
 
GLint getAttribLocation (const std::string &name) const
 
void addShaderToAttach (Shader *shader)
 
void addShaderToDetach (Shader *shader)
 
- Public Member Functions inherited from osg::Referenced
 Referenced ()
 
 Referenced (bool threadSafeRefUnref)
 
 Referenced (const Referenced &)
 
Referencedoperator= (const Referenced &)
 
virtual void setThreadSafeRefUnref (bool threadSafe)
 
bool getThreadSafeRefUnref () const
 
OpenThreads::MutexgetRefMutex () const
 
int ref () const
 
int unref () const
 
int unref_nodelete () const
 
int referenceCount () const
 
ObserverSetgetObserverSet () const
 
ObserverSetgetOrCreateObserverSet () const
 
void addObserver (Observer *observer) const
 
void removeObserver (Observer *observer) const
 

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 Member Functions inherited from osg::Referenced
virtual ~Referenced ()
 
void signalObserversAndDelete (bool signalDelete, bool doDelete) const
 
void deleteUsingDeleteHandler () const
 

Protected Attributes

const Program_program
 
osg::ref_ptr< GLExtensions_extensions
 
GLuint _glProgramHandle
 
std::string _defineStr
 
bool _needsLink
 
bool _isLinked
 
bool _loadedBinary
 
const unsigned int _contextID
 
bool _ownsProgramHandle
 
ActiveUniformMap _uniformInfoMap
 
ActiveVarInfoMap _attribInfoMap
 
UniformBlockMap _uniformBlockMap
 
LastAppliedUniformList _lastAppliedUniformList
 
ShaderList _shadersToDetach
 
ShaderList _shadersToAttach
 
- Protected Attributes inherited from osg::Referenced
OpenThreads::AtomicPtr _observerSet
 
OpenThreads::Atomic _refCount
 

Additional Inherited Members

- Static Public Member Functions inherited from osg::Referenced
static OpenThreads::MutexgetGlobalReferencedMutex ()
 
static void setThreadSafeReferenceCounting (bool enableThreadSafeReferenceCounting)
 
static bool getThreadSafeReferenceCounting ()
 
static void setDeleteHandler (DeleteHandler *handler)
 
static DeleteHandlergetDeleteHandler ()
 

Detailed Description

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

Definition at line 278 of file Program.h.

Member Typedef Documentation

Definition at line 399 of file Program.h.

typedef std::vector< ref_ptr<Shader> > osg::Program::PerContextProgram::ShaderList
protected

Definition at line 402 of file Program.h.

typedef std::pair<osg::ref_ptr<const osg::Uniform>, unsigned int> osg::Program::PerContextProgram::UniformModifiedCountPair
protected

Definition at line 398 of file Program.h.

Constructor & Destructor Documentation

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 ( )
protectedvirtual

Member Function Documentation

void osg::Program::PerContextProgram::addShaderToAttach ( Shader shader)
inline

Definition at line 357 of file Program.h.

void osg::Program::PerContextProgram::addShaderToDetach ( Shader shader)
inline

Definition at line 362 of file Program.h.

void osg::Program::PerContextProgram::apply ( const Uniform uniform) const
inline

Definition at line 317 of file Program.h.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 341 of file Program.h.

const ActiveUniformMap& osg::Program::PerContextProgram::getActiveUniforms ( ) const
inline

Definition at line 340 of file Program.h.

GLint osg::Program::PerContextProgram::getAttribLocation ( const std::string &  name) const
inline

Definition at line 355 of file Program.h.

const std::string& osg::Program::PerContextProgram::getDefineString ( ) const
inline

Definition at line 289 of file Program.h.

GLuint osg::Program::PerContextProgram::getHandle ( ) const
inline

Definition at line 284 of file Program.h.

virtual bool osg::Program::PerContextProgram::getInfoLog ( std::string &  infoLog) const
virtual
const osg::Program* osg::Program::PerContextProgram::getProgram ( ) const
inline

Definition at line 286 of file Program.h.

const UniformBlockMap& osg::Program::PerContextProgram::getUniformBlocks ( ) const
inline

Definition at line 342 of file Program.h.

GLint osg::Program::PerContextProgram::getUniformLocation ( unsigned int  uniformNameID) const
inline

Definition at line 343 of file Program.h.

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.

Definition at line 353 of file Program.h.

Here is the call graph for this function:

Here is the caller graph for this function:

bool osg::Program::PerContextProgram::isLinked ( ) const
inline

Definition at line 295 of file Program.h.

virtual void osg::Program::PerContextProgram::linkProgram ( osg::State state)
virtual
bool osg::Program::PerContextProgram::loadedBinary ( ) const
inline

Was glProgramBinary called successfully?

Definition at line 299 of file Program.h.

bool osg::Program::PerContextProgram::needsLink ( ) const
inline

Definition at line 294 of file Program.h.

void osg::Program::PerContextProgram::requestLink ( )
void osg::Program::PerContextProgram::resetAppliedUniforms ( ) const
inline

Definition at line 311 of file Program.h.

void osg::Program::PerContextProgram::setDefineString ( const std::string &  defStr)
inline

Definition at line 288 of file Program.h.

virtual void osg::Program::PerContextProgram::useProgram ( ) const
virtual
virtual bool osg::Program::PerContextProgram::validateProgram ( )
virtual

Member Data Documentation

ActiveVarInfoMap osg::Program::PerContextProgram::_attribInfoMap
protected

Definition at line 395 of file Program.h.

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

Definition at line 389 of file Program.h.

std::string osg::Program::PerContextProgram::_defineStr
protected

Define string passed on to Shaders to help configure them.

Definition at line 380 of file Program.h.

osg::ref_ptr<GLExtensions> osg::Program::PerContextProgram::_extensions
protected

Pointer to this context's extension functions

Definition at line 374 of file Program.h.

GLuint osg::Program::PerContextProgram::_glProgramHandle
protected

Handle to the actual OpenGL glProgram

Definition at line 377 of file Program.h.

bool osg::Program::PerContextProgram::_isLinked
protected

Is our glProgram successfully linked?

Definition at line 385 of file Program.h.

LastAppliedUniformList osg::Program::PerContextProgram::_lastAppliedUniformList
mutableprotected

Definition at line 400 of file Program.h.

bool osg::Program::PerContextProgram::_loadedBinary
protected

Was glProgramBinary called successfully?

Definition at line 387 of file Program.h.

bool osg::Program::PerContextProgram::_needsLink
protected

Does our glProgram need to be linked?

Definition at line 383 of file Program.h.

bool osg::Program::PerContextProgram::_ownsProgramHandle
protected

Does the glProgram handle belongs to this class?

Definition at line 392 of file Program.h.

const Program* osg::Program::PerContextProgram::_program
protected

Pointer to our parent Program

Definition at line 372 of file Program.h.

ShaderList osg::Program::PerContextProgram::_shadersToAttach
protected

Definition at line 404 of file Program.h.

ShaderList osg::Program::PerContextProgram::_shadersToDetach
protected

Definition at line 403 of file Program.h.

UniformBlockMap osg::Program::PerContextProgram::_uniformBlockMap
protected

Definition at line 396 of file Program.h.

ActiveUniformMap osg::Program::PerContextProgram::_uniformInfoMap
protected

Definition at line 394 of file Program.h.


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