VR-Forces 4.6 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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  virtual void draw_callback();
69 
70 private:
71  void build_shared_tbo();
72  void update_shared_tbo();
73 
74  void create_and_add_shared_tbo_to_state_set(osg::StateSet& state_set);
75 
76  // All instance groups attached to this node.
77  static osg::ref_ptr<osg::Group> s_shared_tbo_node;
78 
79 #ifdef USE_OSG_TEXTURE_BUFFER
80  // Shared TBO OSG version >= 3.2.0
81  static osg::ref_ptr<osg::TextureBuffer> s_osg_texture_buffer;
82  static osg::ref_ptr<osg::Image> s_osg_image;
83 #else
84  // Shared TBO OSG version < 3.2.0
86  static osg::ref_ptr<TextureBufferObjectApplyAttribute> s_diguy_texture_buffer_attribute;
87 #endif
88 
89  osg::ref_ptr<osg::Geode> m_geode;
90  osg::ref_ptr<osg::Geometry> m_geometry;
91  osg::ref_ptr<osg::PrimitiveSet> m_primitiveSet;
92 
93  osg::ref_ptr<osg::Uniform> ufrm_base_matrices_start;
94  osg::ref_ptr<osg::Uniform> ufrm_link_matrices_start;
95  osg::ref_ptr<osg::Uniform> ufrm_link_matrices_count;
96  osg::ref_ptr<osg::Uniform> ufrm_extra_per_instance_data;
97  osg::ref_ptr<osg::Uniform> ufrm_apply_matrices_flag;
98  osg::ref_ptr<osg::Uniform> ufrm_instance_group_color;
99  osg::Group *m_dofStateSetGroup;
100  osg::Group *m_shapeStateSetGroup;
102 };
103 
105 };
106 
107 #endif __diguyOsgGraphicsInstanceGroup_H

Document ID: Generated on Thu Apr 12 03:15:37 EDT 2018 from SVN revision 187986
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)