GL Studio C++ Runtime API
gls_sorted_draw_group.h
1 #ifndef GLS_SORTED_RENDER_GROUP_H_INCLUDED
2 #define GLS_SORTED_RENDER_GROUP_H_INCLUDED
3 
4 #include "gls_sorted_drawable.h"
5 #include "group.h"
6 
7 //////////////////// Provides support for creating DLLs ////////////////////////
8 #if( defined( GLSGEN_EXPORT_GLSADVANCEDMESH ) || defined( GLSGEN_IMPORT_GLSADVANCEDMESH ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
9  && defined( _MSC_VER )
10 # if defined( GLSGEN_EXPORT_GLSADVANCEDMESH ) || defined( GLS_EXPORT_GENERATED )
11 # define GLSGEN_GlsAdvancedMesh_EXPORT __declspec( dllexport )
12 # else
13 # define GLSGEN_GlsAdvancedMesh_EXPORT __declspec( dllimport )
14 # endif
15 #else
16 # define GLSGEN_GlsAdvancedMesh_EXPORT
17 #endif
18 ///////////////////////////////////////////////////////////////////////////////
19 
20 namespace disti
21 {
22 class GlsRenderEffect;
23 class GlsGeometryResource;
24 class GlsSortedDrawable;
25 class GlsDeferredDrawGroup;
26 
27 // This Group allows it's children to register into
28 // a list during Draw. The Group then sorts the list
29 // and draws the children.
30 class GlsSortedDrawGroup : public Group
31 {
32 public:
33  DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
34  typedef Group _BaseClass;
35  typedef Group BaseClass;
36 
37  GLSGEN_GlsAdvancedMesh_EXPORT GlsSortedDrawGroup();
38 
39  class DrawList
40  {
41  friend class GlsSortedDrawGroup;
42 
43  public:
44  void RegisterDrawable( GlsSortedDrawable* obj );
45 
46  protected:
47  typedef std::vector<GlsSortedDrawable*> EntryListT;
48  typedef std::vector<GlsDeferredDrawGroup*> DeferredDrawListT;
49  EntryListT drawEntryList;
50  EntryListT orderPreservedDrawList;
51  DeferredDrawListT deferredDrawList;
52  unsigned long drawEntryListCount;
53  unsigned long orderPreservedDrawListCount;
54 
55  DrawList()
56  : drawEntryListCount( 0 )
57  , orderPreservedDrawListCount( 0 )
58  {}
59 
60  // Sort the list using GlsSortedDrawable::SortedDraw_Compare
61  void Sort();
62 
63  // Optimize the nodes using GlsSortedDrawable::SortedDraw_MergeEffects
64  // Should only be called after the list is sorted
65  void Optimize();
66 
67  // Draw the nodes
68  void Draw();
69 
70  // Clear the list
71  void Clear();
72  };
73 
74  /* See base class */
75  virtual GLSGEN_GlsAdvancedMesh_EXPORT void Draw( void );
76 
77  // Returns pointer to the active GlsSortedDrawGroup::DrawList for the calling thread
78  // This will be NULL if there is no active DrawList.
79  static GLSGEN_GlsAdvancedMesh_EXPORT DrawList* GetActiveDrawListPtr();
80 
81  // Disable sorted draw to render normally
82  // Toggling this value between frames is a good way to debug any rendering issues
83  GLSGEN_GlsAdvancedMesh_EXPORT void DisableSortedDraw( bool value );
84  GLSGEN_GlsAdvancedMesh_EXPORT bool DisableSortedDraw();
85 
86 protected:
87  // Set the active GlsSortedDrawGroup::DrawList for the calling thread
88  static GLSGEN_GlsAdvancedMesh_EXPORT void SetActiveDrawListPtr( DrawList* );
89 
90  bool _sortedDrawDisabled;
91  DrawList _drawList;
92 };
93 
94 } // end namespace disti
95 
96 #endif
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:436
virtual void Draw(void)
The disti::Group class. Implements groups of objects.
Definition: gls_sorted_draw_group.h:39
Definition: gls_sorted_drawable.h:47
Definition: display.h:98
Definition: gls_sorted_draw_group.h:30
Definition: group.h:52
A sorted drawable group.
Definition: bmpimage.h:46