VR-Forces Development_Version Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtOsgShaderUtils.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2013 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 #include <boost/unordered_map.hpp>
14 #include <string>
15 #include <vector>
16 
17 #include <osg/StateAttribute>
18 
19 // forward declarations
20 namespace osg
21 {
22  class State;
23  class StateSet;
24  class Texture;
25  class Node;
26  class Uniform;
27 }
28 
29 namespace makVrv
30 {
32 
33  typedef boost::unordered_map<void *, int> UniformLocationMap;
34  typedef boost::unordered_map<int, UniformLocationMap> ShaderUniLocMap;
35 
36 
38  {
39 
40 
41  public:
43  static std::string loadShaderSource(const std::string& strFileName);
44 
46  static void saveShaderSource(const std::string& strFileName, const std::string& strSource);
47 
48  static std::string fixVersionDirective(const std::string &shaderString);
49 
51  static unsigned getNumGPUTextureImageUnits();
52 
54  // hashPtr is just a pointer to use for the location hash. it should be unique for each uniform set this way
55  // for an example look at how DtSpeedTreeForest uses this
56  static void bindSingleAttribute(int shader, std::string uniName, bool value, void *hashPtr);
57 
61  static void bindAttributes(osg::Node *node, int shader, int contextID);
62 
68  static bool getVPShaderVector(osg::StateSet *ss, osg::State& state, unsigned int &shaderHash, std::vector<unsigned int> &vertShaderVector, std::vector<unsigned int> &fragShaderVector);
69 
70 
72  static void deleteShaders(std::vector<unsigned int> shaderVector);
73 
77  static bool compileShader(const char* source, unsigned int shaderType, unsigned int &shaderID);
78 
79  static void restoreOpenGLMode(osg::State& state, int stateToSet);
80  static void restoreOpenGLStateAttribute(osg::State& state, osg::StateAttribute::Type type);
81  static void restoreOpenGLProgram(osg::State& state);
82  static void restoreOpenGLFBO(osg::State& state);
83  private:
84 
89  };
90 
91 }

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)