GL Studio API
gls_sorted_drawable.h
1 #ifndef GLS_SORTED_DRAWABLE_H
2 #define GLS_SORTED_DRAWABLE_H
3 
4 namespace disti {
5 
6 // Interface for a drawable object
8 {
9 public:
10  // virtual destructor
11  virtual ~GlsSortedDrawable() {}
12 
13  // Allows for static casting in compare functions
14  // See RegisterClassID
15  virtual unsigned int SortedDraw_ClassID() = 0;
16 
17  // Compare two GlsSortedDrawable objects to determine the sort order
18  // \param other object to compare to
19  // \returns true if this object should draw before other
20  virtual bool SortedDraw_Compare(GlsSortedDrawable& other) = 0;
21 
22  // Comparison that should be used if the
23  // derived class is unsure
24  inline bool SortedDraw_CompareDefault(GlsSortedDrawable& o)
25  {
26  // Group objects by ClassID
27  return SortedDraw_ClassID() < o.SortedDraw_ClassID();
28  }
29 
30  // Try to merge two adjecently-sorted GlsSortedDrawable nodes
31  // \param lastObj pointer to the previous GlsSortedDrawable in the sort order
32  virtual void SortedDraw_OptimizeMerge(GlsSortedDrawable& lastObj) = 0;
33 /*
34  // Return true if this object should be depth sorted
35  virtual bool SortedDraw_ShouldDepthSort() { return false; }
36 
37  // Return position of the object for depth sorting purposes
38  virtual void SortedDraw_GetViewPosition(Vector& pos) {}
39 */
40  // Draw the object using the current OpenGL context
41  // Use lastDrawnObj to avoid redundant state changes
42  // \param lastObj pointer to the GlsSortedDrawable that was drawn (may be NULL)
43  virtual void SortedDraw(GlsSortedDrawable* lastObj) = 0;
44 
45  // Tell an object to restore the OpenGLDefaultState after drawing
46  // Objects should call this if lastDrawnObj has an unknown class
47  // The Group will also call this after the last object is drawn
48  virtual void SortedDrawCleanup() = 0;
49 
50  //Whether or not this can be re-ordered, or if it is part of an preserved order set
51  virtual bool SortedDraw_ReorderAtWill() { return true; }
52 
53  // Returns a new ClassID
54  // Typically only called once by each GlsSortedDrawable implementation
55  static unsigned int RegisterNewClassID(const char* debugStr = NULL);
56 };
57 
58 }
59 
60 #endif
Definition: gls_sorted_drawable.h:7
Definition: bmpimage.h:46