VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtDiGuyOsgGraphicsInstanceGroup.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2016 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 #ifndef __diguyOsgGraphicsInstanceGroup_H
7 #define __diguyOsgGraphicsInstanceGroup_H
8 
9 /*
10  * Note: Requires OSG 3.2 or greater for texture buffer object support.
11  */
12 
13 #include <osg/Version>
14 
15 /*
16  * OSG > 3.2.0 has native support for texture buffer objects
17  * via osg::TextureBuffer. For versions of OSG prior to 3.2.0,
18  * support for texture buffer objects is provided in the classes
19  * diguyOsgTextureBufferObject and diguyOsgTextureBufferApplyAttribute.
20  */
21 #if OSG_MIN_VERSION_REQUIRED(3,2,0)
22 //#define USE_OSG_TEXTURE_BUFFER 1
23 #else
24 #endif
25 
26 /*
27  * USE_SHARED_TBO uses a single texture buffer object to store
28  * the data for all instance groups. If USE_SHARED_TBO is not
29  * defined, each instance group uses a separate TBO to store
30  * data for the instance group.
31  */
32 #define USE_SHARED_TBO
33 
34 #if USE_OSG_TEXTURE_BUFFER
35 #include <osg/TextureBuffer>
36 #endif
37 
38 #include <vrvOsg/vrvOsg.h>
40 
41 #include <osg/Geode>
42 #include <vrvDiGuy/vrvDiGuy.h>
43 #include <diguyGraphicsInstanceGroup.h>
44 
45 namespace makVrv
46 {
47 
48  class DtGLTextureBufferObject;
49 
50 /*********************************************************************/
60 {
61 public:
62  diguyOsgGraphicsInstanceGroup(void* internal_data);
64 
65  virtual void build();
66  virtual void unbuild();
67  virtual void update();
68 
69 private:
70  void build_shared_tbo();
71  void update_shared_tbo();
72 
73  void create_and_add_shared_tbo_to_state_set(osg::StateSet& state_set);
74 
75  // All instance groups attached to this node.
76  static osg::ref_ptr<osg::Group> s_shared_tbo_node;
77 
78 #ifdef USE_OSG_TEXTURE_BUFFER
79  // Shared TBO OSG version >= 3.2.0
80  static osg::ref_ptr<osg::TextureBuffer> s_osg_texture_buffer;
81  static osg::ref_ptr<osg::Image> s_osg_image;
82 #else
83  // Shared TBO OSG version < 3.2.0
85  static osg::ref_ptr<TextureBufferObjectApplyAttribute> s_diguy_texture_buffer_attribute;
86 #endif
87 
88  osg::ref_ptr<osg::Geode> m_geode;
89  osg::ref_ptr<osg::Geometry> m_geometry;
90  osg::ref_ptr<osg::PrimitiveSet> m_primitiveSet;
91 
92  osg::ref_ptr<osg::Uniform> ufrm_base_matrices_start;
93  osg::ref_ptr<osg::Uniform> ufrm_link_matrices_start;
94  osg::ref_ptr<osg::Uniform> ufrm_link_matrices_count;
95  osg::ref_ptr<osg::Uniform> ufrm_extra_per_instance_data;
96  osg::ref_ptr<osg::Uniform> ufrm_apply_matrices_flag;
97  osg::ref_ptr<osg::Uniform> ufrm_instance_group_color;
98  osg::Group *m_dofStateSetGroup;
99  osg::Group *m_shapeStateSetGroup;
101 };
102 
104 };
105 
106 #endif __diguyOsgGraphicsInstanceGroup_H

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)