VR-Forces Development_Version Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Static Public Member Functions | Static Private Attributes
makVrv::DtOsgShaderUtils Class Reference

Static Public Member Functions

static std::string loadShaderSource (const std::string &strFileName)
 Loads shader source code from a file.
static void saveShaderSource (const std::string &strFileName, const std::string &strSource)
 Saves shader source code to a file.
static std::string fixVersionDirective (const std::string &shaderString)
static unsigned getNumGPUTextureImageUnits ()
 Query the number of available texture image units for shader samplers.
static void bindSingleAttribute (int shader, std::string uniName, bool value, void *hashPtr)
 attaches a single attribute to a opengl uniform.
static void bindAttributes (osg::Node *node, int shader, int contextID)
 Loop over the uniforms of the stateset of the node and attach them to the current opengl active shader.
static bool getVPShaderVector (osg::StateSet *ss, osg::State &state, unsigned int &shaderHash, std::vector< unsigned int > &vertShaderVector, std::vector< unsigned int > &fragShaderVector)
 Collect all the active osg::Shader objects in the provided State and compile them.
static void deleteShaders (std::vector< unsigned int > shaderVector)
 Loop over the opengl shader ids in the shaderVector and deletes them from opengl.
static bool compileShader (const char *source, unsigned int shaderType, unsigned int &shaderID)
 Compiles a shader of type shaderType using source.
static void restoreOpenGLMode (osg::State &state, int stateToSet)
static void restoreOpenGLStateAttribute (osg::State &state, osg::StateAttribute::Type type)
static void restoreOpenGLProgram (osg::State &state)
static void restoreOpenGLFBO (osg::State &state)

Static Private Attributes

static ShaderUniLocMap s_shaderUniLocMap
 used to cache the shader uniform locations to avoid glGetUniformLocation calls Saves somewhere between 1-3ms and reduces variability of frame time with Triton and Silverlining Tried caching the uniform values as well but that did not seem to make a difference.

Member Function Documentation

static std::string makVrv::DtOsgShaderUtils::loadShaderSource ( const std::string &  strFileName)
static

Loads shader source code from a file.

static void makVrv::DtOsgShaderUtils::saveShaderSource ( const std::string &  strFileName,
const std::string &  strSource 
)
static

Saves shader source code to a file.

static std::string makVrv::DtOsgShaderUtils::fixVersionDirective ( const std::string &  shaderString)
static
static unsigned makVrv::DtOsgShaderUtils::getNumGPUTextureImageUnits ( )
static

Query the number of available texture image units for shader samplers.

static void makVrv::DtOsgShaderUtils::bindSingleAttribute ( int  shader,
std::string  uniName,
bool  value,
void *  hashPtr 
)
static

attaches a single attribute to a opengl uniform.

static void makVrv::DtOsgShaderUtils::bindAttributes ( osg::Node *  node,
int  shader,
int  contextID 
)
static

Loop over the uniforms of the stateset of the node and attach them to the current opengl active shader.

Also loops over the texture attributes in the stateset and attaches those as well

static bool makVrv::DtOsgShaderUtils::getVPShaderVector ( osg::StateSet *  ss,
osg::State &  state,
unsigned int &  shaderHash,
std::vector< unsigned int > &  vertShaderVector,
std::vector< unsigned int > &  fragShaderVector 
)
static

Collect all the active osg::Shader objects in the provided State and compile them.

If they compile they are pushed onto shaderVector. shaderVector is cleared in this function so only the shaders from the State are kept. The stateset "ss" is then cleared of an update mark. Returns True if the ss was marked for an update and the shaderVector was modified.

static void makVrv::DtOsgShaderUtils::deleteShaders ( std::vector< unsigned int >  shaderVector)
static

Loop over the opengl shader ids in the shaderVector and deletes them from opengl.

static bool makVrv::DtOsgShaderUtils::compileShader ( const char source,
unsigned int  shaderType,
unsigned int &  shaderID 
)
static

Compiles a shader of type shaderType using source.

shaderID is the new shader Returns True is the compile succeeded

static void makVrv::DtOsgShaderUtils::restoreOpenGLMode ( osg::State &  state,
int  stateToSet 
)
static
static void makVrv::DtOsgShaderUtils::restoreOpenGLStateAttribute ( osg::State &  state,
osg::StateAttribute::Type  type 
)
static
static void makVrv::DtOsgShaderUtils::restoreOpenGLProgram ( osg::State &  state)
static
static void makVrv::DtOsgShaderUtils::restoreOpenGLFBO ( osg::State &  state)
static

Member Data Documentation

ShaderUniLocMap makVrv::DtOsgShaderUtils::s_shaderUniLocMap
staticprivate

used to cache the shader uniform locations to avoid glGetUniformLocation calls Saves somewhere between 1-3ms and reduces variability of frame time with Triton and Silverlining Tried caching the uniform values as well but that did not seem to make a difference.


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

Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)