VR-Forces 4.5 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) 2017 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
14 
16 
17 #include <boost/unordered_map.hpp>
18 
19 #include <osg/StateAttribute>
20 
21 // forward declarations
22 namespace osg
23 {
24  class State;
25  class StateSet;
26  class Texture;
27  class Node;
28  class Uniform;
29 }
30 
31 namespace makVrv
32 {
34 
35 
36  typedef boost::unordered_map<void *, int> UniformLocationMap;
37  typedef boost::unordered_map<int, UniformLocationMap> ShaderUniLocMap;
38 
39 
41  {
42 
43  public:
45  static std::string loadShaderSource(const std::string& strFileName);
46 
48  static void saveShaderSource(const std::string& strFileName, const std::string& strSource);
49 
50  static std::string fixVersionDirective(const std::string &shaderString);
51 
53  static unsigned getNumGPUTextureImageUnits();
54 
56  // hashPtr is just a pointer to use for the location hash. it should be unique for each uniform set this way
57  // for an example look at how DtSpeedTreeForest uses this
58  static void bindSingleAttribute(int shader, const std::string& uniName, bool value, void *hashPtr);
59 
63  static void bindAttributes(osg::Node *node, int shader, int contextID);
64 
70  static bool getVPShaderVector(osg::StateSet *ss, osg::State& state, unsigned int &shaderHash, std::vector<unsigned int> &vertShaderVector, std::vector<unsigned int> &fragShaderVector);
71 
72 
74  static void deleteShaders(const std::vector<unsigned int>& shaderVector);
75 
79  static bool compileShader(const char* source, unsigned int shaderType, unsigned int &shaderID);
80 
81  static void restoreOpenGLMode(osg::State& state, int stateToSet);
82  static void restoreOpenGLStateAttribute(osg::State& state, osg::StateAttribute::Type type);
83  static void restoreOpenGLProgram(osg::State& state);
84  static void restoreOpenGLFBO(osg::State& state);
85  static void markAllTextureAttributesDirty(osg::State & state);
86 
91  static void generateModelInstanceShaders(osg::Node *node, const std::string& shaderName);
92 
93  private:
94 
99  };
100 
101 
102 
103 }

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)