VR-Forces 4.3 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) 1992-2014 VT MAK
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);
63 
64  virtual void build();
65  virtual void unbuild();
66  virtual void update();
67 
68 private:
69  void build_tbo_per_group();
70  void build_shared_tbo();
71 
72  void update_tbo_per_group();
73  void update_shared_tbo();
74 
75  void create_and_add_tbo_to_state_set(osg::StateSet& state_set);
76  void create_and_add_shared_tbo_to_state_set(osg::StateSet& state_set);
77 
78  // All instance groups attached to this node.
79  static osg::ref_ptr<osg::Group> s_shared_tbo_node;
80 
81 #ifdef USE_OSG_TEXTURE_BUFFER
82  // Shared TBO OSG version >= 3.2.0
83  static osg::ref_ptr<osg::TextureBuffer> s_osg_texture_buffer;
84  static osg::ref_ptr<osg::Image> s_osg_image;
85 
86  // TBO per group OSG version >= 3.2.0
87  osg::ref_ptr<osg::TextureBuffer> m_osg_texture_buffer;
88  osg::ref_ptr<osg::Image> m_osg_image;
89 #else
90  // Shared TBO OSG version < 3.2.0
92  static osg::ref_ptr<TextureBufferObjectApplyAttribute> s_diguy_texture_buffer_attribute;
93 
94  // TBO per group OSG version < 3.2.0
96  osg::ref_ptr<TextureBufferObjectApplyAttribute> m_diguy_texture_buffer_attribute;
97 #endif
98 
99  osg::ref_ptr<osg::Geode> m_geode;
100  osg::ref_ptr<osg::Geometry> m_geometry;
101  osg::ref_ptr<osg::PrimitiveSet> m_primitiveSet;
102 
103  osg::ref_ptr<osg::Uniform> ufrm_link_matrices_start;
104  osg::ref_ptr<osg::Uniform> ufrm_link_matrices_count;
105  osg::ref_ptr<osg::Uniform> ufrm_apply_matrices_flag;
106 };
107 
109 };
110 
111 #endif __diguyOsgGraphicsInstanceGroup_H

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)