VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtOsgShaderUtils.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
14 
16 
17 #include <osg/StateAttribute>
18 
19 #include <unordered_map>
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 {
33  class DtOsgFileCache;
34 
37  {
38  private:
40  DtOsgShaderUtils() = delete;
41 
43  DtOsgShaderUtils(const DtOsgShaderUtils& rhs) = delete;
44 
46  DtOsgShaderUtils& operator = (const DtOsgShaderUtils& rhs) = delete;
47 
49  virtual ~DtOsgShaderUtils() = delete;
50 
51  public:
56  static void bindAttributes(const osg::GLExtensions * ext, const osg::StateSet *ss, int shader, int contextID);
57 
63  static bool getVPShaderVector(osg::StateSet *ss, osg::State& state, unsigned int &shaderHash,
64  std::vector<unsigned int> &vertShaderVector, std::vector<unsigned int> &fragShaderVector, bool skip_shadow_shaders = false, bool skip_multiview_shaders = false);
65 
67  static bool addDegenerateShadersIfNeeded(osg::StateSet *ss, osg::State& state,
68  std::vector<unsigned int> &vertShaderVector, std::vector<unsigned int> &fragShaderVector, bool skip_shadow_shaders = false);
69 
70  static void restoreEverything(osg::State& state);
71 
73  static void restoreOpenGLMode(const osg::State& state, int stateToSet);
74 
76  static void restoreOpenGLStateAttribute(osg::State& state, osg::StateAttribute::Type type);
77 
79  static void restoreOpenGLProgram(const osg::State& state);
80 
82  static void restoreOpenGLFBO(const osg::State& state);
83 
85  static void markAllTextureAttributesDirty(osg::State & state);
86 
91  static void generateModelInstanceShaders(osg::Node *node, const std::string& shaderName);
92 
94  static unsigned getNumGPUTextureImageUnits();
95 
98  static void clearCachedProgramsAndUniformLocations(void);
99 
100  protected:
101 
103  {
104  CachedUniformData() : location(-1), modCount(0), uniform(0) { ; }
105  int location;
106  int modCount;
107  void * uniform;
108  };
109  typedef std::unordered_map<unsigned int, CachedUniformData > UniformLocationMap;
110  typedef std::unordered_map<int, UniformLocationMap> ShaderUniLocMap;
111 
116  };
117 
118 
119 
120 }
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
int location
Definition: DtOsgShaderUtils.h:105
Definition: DtOsgShaderUtils.h:102
std::unordered_map< unsigned int, CachedUniformData > UniformLocationMap
Definition: DtOsgShaderUtils.h:109
Contains makVrv::DtVirtualBaseClass class.
int modCount
Definition: DtOsgShaderUtils.h:106
CachedUniformData()
Definition: DtOsgShaderUtils.h:104
Miscellaneous shader utilities for osg.
Definition: DtOsgShaderUtils.h:36
void * uniform
Definition: DtOsgShaderUtils.h:107
static ShaderUniLocMap theShaderUniLocMap
used to cache the shader uniform locations to avoid glGetUniformLocation calls Saves somewhere betwee...
Definition: DtOsgShaderUtils.h:115
Contains DLL export macros.
std::unordered_map< int, UniformLocationMap > ShaderUniLocMap
Definition: DtOsgShaderUtils.h:110

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)