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  typedef Group _BaseClass;
34 
35  GLSGEN_GlsAdvancedMesh_EXPORT GlsSortedDrawGroup();
36 
37  class DrawList
38  {
39  friend class GlsSortedDrawGroup;
40 
41  public:
42  void RegisterDrawable( GlsSortedDrawable* obj );
43 
44  protected:
45  typedef std::vector<GlsSortedDrawable*> EntryListT;
46  typedef std::vector<GlsDeferredDrawGroup*> DeferredDrawListT;
47  EntryListT drawEntryList;
48  EntryListT orderPreservedDrawList;
49  DeferredDrawListT deferredDrawList;
50  unsigned long drawEntryListCount;
51  unsigned long orderPreservedDrawListCount;
52 
53  DrawList()
54  : drawEntryListCount( 0 )
55  , orderPreservedDrawListCount( 0 )
56  {}
57 
58  // Sort the list using GlsSortedDrawable::SortedDraw_Compare
59  void Sort();
60 
61  // Optimize the nodes using GlsSortedDrawable::SortedDraw_MergeEffects
62  // Should only be called after the list is sorted
63  void Optimize();
64 
65  // Draw the nodes
66  void Draw();
67 
68  // Clear the list
69  void Clear();
70  };
71 
72  /* See base class */
73  virtual GLSGEN_GlsAdvancedMesh_EXPORT void Draw( void );
74 
75  // Returns pointer to the active GlsSortedDrawGroup::DrawList for the calling thread
76  // This will be NULL if there is no active DrawList.
77  static GLSGEN_GlsAdvancedMesh_EXPORT DrawList* GetActiveDrawListPtr();
78 
79  // Disable sorted draw to render normally
80  // Toggling this value between frames is a good way to debug any rendering issues
81  GLSGEN_GlsAdvancedMesh_EXPORT void DisableSortedDraw( bool value );
82  GLSGEN_GlsAdvancedMesh_EXPORT bool DisableSortedDraw();
83 
84 protected:
85  // Set the active GlsSortedDrawGroup::DrawList for the calling thread
86  static GLSGEN_GlsAdvancedMesh_EXPORT void SetActiveDrawListPtr( DrawList* );
87 
88  bool _sortedDrawDisabled;
89  DrawList _drawList;
90 };
91 
92 } // end namespace disti
93 
94 #endif
virtual void Draw(void)
The disti::Group class. Implements groups of objects.
Definition: gls_sorted_draw_group.h:37
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