GL Studio 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 "group.h"
5 #include "gls_sorted_drawable.h"
6 
7 //////////////////// Provides support for creating DLLs ////////////////////////
8 #if (defined(GLSGEN_EXPORT_GLSADVANCEDMESH) || \
9  defined(GLSGEN_IMPORT_GLSADVANCEDMESH) || \
10  defined(GLS_EXPORT_GENERATED) || \
11  defined(GLS_IMPORT_GENERATED)) \
12  && defined(_MSC_VER)
13 # if defined(GLSGEN_EXPORT_GLSADVANCEDMESH) || defined(GLS_EXPORT_GENERATED)
14 # define GLSGEN_GlsAdvancedMesh_EXPORT __declspec(dllexport)
15 # else
16 # define GLSGEN_GlsAdvancedMesh_EXPORT __declspec(dllimport)
17 # endif
18 #else
19 # define GLSGEN_GlsAdvancedMesh_EXPORT
20 #endif
21 ///////////////////////////////////////////////////////////////////////////////
22 
23 namespace disti {
24 
25 class GlsRenderEffect;
26 class GlsGeometryResource;
27 class GlsSortedDrawable;
28 class GlsDeferredDrawGroup;
29 
30 // This Group allows it's children to register into
31 // a list during Draw. The Group then sorts the list
32 // and draws the children.
33 class GlsSortedDrawGroup : public Group {
34 public:
35  typedef Group _BaseClass;
36 
37  GLSGEN_GlsAdvancedMesh_EXPORT GlsSortedDrawGroup();
38 
39  class DrawList {
40  friend class GlsSortedDrawGroup;
41  public:
42  void RegisterDrawable(GlsSortedDrawable* obj);
43  protected:
44  typedef std::vector<GlsSortedDrawable*> EntryListT;
45  typedef std::vector<GlsDeferredDrawGroup*> DeferredDrawListT;
46  EntryListT drawEntryList;
47  EntryListT orderPreservedDrawList;
48  DeferredDrawListT deferredDrawList;
49  unsigned long drawEntryListCount;
50  unsigned long orderPreservedDrawListCount;
51 
52  DrawList():
53  drawEntryListCount(0),
54  orderPreservedDrawListCount(0)
55  {}
56 
57  // Sort the list using GlsSortedDrawable::SortedDraw_Compare
58  void Sort();
59 
60  // Optimize the nodes using GlsSortedDrawable::SortedDraw_MergeEffects
61  // Should only be called after the list is sorted
62  void Optimize();
63 
64  // Draw the nodes
65  void Draw();
66 
67  // Clear the list
68  void Clear();
69  };
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
95 
virtual void Draw(void)
The disti::Group class. Implements groups of objects.
Definition: gls_sorted_draw_group.h:39
Definition: gls_sorted_drawable.h:7
Definition: display.h:98
Definition: gls_sorted_draw_group.h:33
Definition: group.h:53
Definition: bmpimage.h:46