VR-Forces 4.6.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtIndirectGeometry.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2018 VT-MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
15 
18 
20 
21 #include <osg/Drawable>
22 #include <osg/Uniform>
23 
24 #include <boost/unordered_map.hpp>
25 #include <tbb/atomic.h>
26 #include <tbb/concurrent_queue.h>
27 
28 #include <string>
29 
30 #define INDIRECTGEOMETRY_CONSTRUCT_DESTRUCT_DEBUG 0
31 
32 namespace osg
33 {
34  class NodeVisitor;
35  class State;
36 }
37 
38 namespace osgUtil
39 {
40  class CullVisitor;
41 }
42 
43 namespace makVrv
44 {
45  class DtIndirectGeometryRegistrar;
46  class DtGpuCullingAndLod;
47  class DtGlBuffer;
48  class DtOsgShaderFilesCache;
49 
59  {
60  public:
63 
66 
67  public:
68 
70  void insertMode(int index, bool enable, int mode);
71 
73  void applyMode(int index) const;
74 
76  void restoreAllModes(osg::State &state) const;
77 
79  int numberOfStates() const;
80 
81  protected:
82 
83  typedef std::pair<bool, int> GlModeSetting;
84  typedef std::vector<GlModeSetting> GlModeVec;
86 
87  typedef std::set<int> GlModeSet;
89  };
90 
96  class DT_DLL_VRVOSG DtIndirectGeometry : public osg::Drawable
97  {
98  public:
99 
100 
102  {
103  CullFaceOnState = 0,
104  CullFaceOffState = 1,
105  NumStates = 2
106  };
107 
108  public:
132  DtIndirectGeometry(DtIndirectGeometryRegistrar* registrar, bool viewFrustumCulling, bool lodChecking, bool useInstanceCount);
133 
137  virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
138 
140  virtual void addInstance(const DtInstance_64& instance);
141 
143  virtual void removeAllInstances(void);
144 
148  virtual void accept(osg::NodeVisitor& nv);
149 
151  virtual void setParent(const osg::Group* parent);
152 
156  virtual void setDebugDrawString(const std::string& drawString);
157 
163  virtual void setRegistrarInvalid(void);
164 
165  virtual void releaseGLObjects(osg::State* state) const;
166 
167  protected:
170 
172  virtual ~DtIndirectGeometry();
173 
174 
178  virtual void addInstanceActual(const DtInstance_64& instance);
179  virtual bool actuallyAddQueuedUpInstances(void);
180 
182  virtual void setVisibility(bool visibility);
183 
187  virtual GLuint getOrCreateAndRecordVAO(const osg::RenderInfo& renderInfo) const;
188  virtual void clearVAO(const osg::RenderInfo& renderInfo);
189  virtual void recordVAO(GLuint vao) const;
190 
194  virtual void slot_rebuild(const DtIndirectGeometryRegistrar::RebuildResult& result);
195 
198  virtual void setUpShadersIfNecessary(osgUtil::CullVisitor* cullVisitor);
199 
201  virtual void installIndirectRenderingProgram(DtOsgShaderFilesCache* shaderFilesCache, const std::string& shaderFolderPath, osg::StateSet* ss) const;
202 
205  virtual void installDefaultMaterial(osg::StateSet* ss);
206 
207  protected:
210 
213 
215  tbb::concurrent_queue<DtInstance_64> myQueueInstancesToAdd;
216 
217  typedef boost::unordered_map<unsigned int, GLuint> MapContextToVAO;
219 
221 
223 
225 
226  osg::ref_ptr<osg::Uniform> myViewMatrix;
227  osg::ref_ptr<osg::Uniform> myProjectionMatrix;
228 
229  std::string myDrawString;
230 
231  mutable bool myMutableShadersSetup;
232 
234 
235 #if INDIRECTGEOMETRY_CONSTRUCT_DESTRUCT_DEBUG
236  static tbb::atomic<int> myRefCount;
237 #endif
238  };
239 
242  {
243  public:
246 
248  virtual ~DtIndirectGeometryCreator();
249 
251  virtual DtIndirectGeometry* create(DtIndirectGeometryRegistrar* registrar, bool viewFrustumCulling, bool lodChecking, bool useInstanceCount) const;
252 
255  static DtIndirectGeometryCreator& instance(DtDe& de);
256 
258  static const std::string& theClassName();
259  protected:
261  };
262 
263 }

Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)