| GL Studio C++ Runtime API

gls_sorted_draw_group.h
Go to the documentation of this file.
1/// \file
2/// \brief A sorted drawable group.
3///
4/// \par Copyright Information
5///
6/// Copyright (c) 2022 by The DiSTI Corporation.<br>
7/// 11301 Corporate Blvd; Suite 100<br>
8/// Orlando, Florida 32817<br>
9/// USA<br>
10/// <br>
11/// All rights reserved.<br>
12///
13/// This Software contains proprietary trade secrets of DiSTI and may not be
14/// reproduced, in whole or part, in any form, or by any means of electronic,
15/// mechanical, or otherwise, without the written permission of DiSTI. Said
16/// permission may be derived through the purchase of applicable DiSTI product
17/// licenses which detail the distribution rights of this content and any
18/// Derivative Works based on this or other copyrighted DiSTI Software.
19///
20/// NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21/// AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22/// PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23/// AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24/// IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25/// PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26///
27/// LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28/// IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29/// INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30/// DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31/// INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32/// INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33/// OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34/// EXCEED FIVE DOLLARS (US$5.00).
35///
36/// The aforementioned terms and restrictions are governed by the laws of the
37/// State of Florida and the United States of America.
38
39#ifndef GLS_SORTED_RENDER_GROUP_H_INCLUDED
40#define GLS_SORTED_RENDER_GROUP_H_INCLUDED
41
42#include "gls_sorted_drawable.h"
43#include "group.h"
44
45/// Provides support for creating DLLs.
46#if( defined( GLSGEN_EXPORT_GLSADVANCEDMESH ) || defined( GLSGEN_IMPORT_GLSADVANCEDMESH ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
47 && defined( _MSC_VER )
48# if defined( GLSGEN_EXPORT_GLSADVANCEDMESH ) || defined( GLS_EXPORT_GENERATED )
49# define GLSGEN_GlsAdvancedMesh_EXPORT __declspec( dllexport )
50# else
51# define GLSGEN_GlsAdvancedMesh_EXPORT __declspec( dllimport )
52# endif
53#else
54# define GLSGEN_GlsAdvancedMesh_EXPORT
55#endif
56///////////////////////////////////////////////////////////////////////////////
57
58 namespace disti
59{
60 class GlsRenderEffect;
61 class GlsGeometryResource;
62 class GlsSortedDrawable;
63 class GlsDeferredDrawGroup;
64
65/// \details This Group allows it's children to register into a list during Draw. The Group then sorts the list and draws the children.
66 class GlsSortedDrawGroup : public Group
67{
68 public:
69 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
70 typedef Group _BaseClass; ///< Deprecated typedef for the base class.
71 typedef Group BaseClass; ///< Typedef for the base class.
72
73 GLSGEN_GlsAdvancedMesh_EXPORT GlsSortedDrawGroup();
74
75 /// \details The DrawList class. Holds a list of objects for sorting and drawing.
76 class DrawList
77 {
78 friend class GlsSortedDrawGroup;
79
80 public:
81 /// Register the incoming drawable object with this list.
82 /// \param obj The new object to register.
83 void RegisterDrawable( GlsSortedDrawable* obj );
84
85 protected:
86 typedef std::vector<GlsSortedDrawable*> EntryListT; ///< Typedef for a list of drawables.
87 typedef std::vector<GlsDeferredDrawGroup*> DeferredDrawListT; ///< Unused.
88 EntryListT drawEntryList; ///< List of drawables in sorted order.
89 EntryListT orderPreservedDrawList; ///< List of drawables in orginal order.
90 DeferredDrawListT deferredDrawList; ///< Unused.
91 unsigned long drawEntryListCount; ///< Number of elements in the entry list.
92 unsigned long orderPreservedDrawListCount; ///< Number of elements in the original order list.
93
94 DrawList()
95 : drawEntryListCount( 0 )
96 , orderPreservedDrawListCount( 0 )
97 {}
98
99 /// Sort the list using GlsSortedDrawable::SortedDraw_Compare.
100 void Sort();
101
102 /// Optimize the nodes using GlsSortedDrawable::SortedDraw_MergeEffects.
103 /// Should only be called after the list is sorted.
104 void Optimize();
105
106 /// Draw the nodes.
107 void Draw();
108
109 /// Clear the list.
110 void Clear();
111 };
112
113 virtual GLSGEN_GlsAdvancedMesh_EXPORT void Draw() DISTI_METHOD_OVERRIDE;
114
115 /// \return A pointer to the active GlsSortedDrawGroup::DrawList for the calling thread.
116 /// \note This will be NULL if there is no active DrawList.
117 static GLSGEN_GlsAdvancedMesh_EXPORT DrawList* GetActiveDrawListPtr();
118
119 /// Disable sorted draw to render normally.
120 /// Toggling this value between frames is a good way to debug any rendering issues.
121 /// \param value The sorting draw flag to set.
122 GLSGEN_GlsAdvancedMesh_EXPORT void DisableSortedDraw( bool value );
123
124 /// \return Whether or not objects should be drawn sorted, or in original order.
125 GLSGEN_GlsAdvancedMesh_EXPORT bool DisableSortedDraw();
126
127protected:
128 /// Set the active GlsSortedDrawGroup::DrawList for the calling thread.
129 static GLSGEN_GlsAdvancedMesh_EXPORT void SetActiveDrawListPtr( DrawList* );
130
131 bool _sortedDrawDisabled; ///< If true, draw in original order rather than sorted order.
132 DrawList _drawList; ///< Holds sorting and object data.
133};
134
135} // end namespace disti
136
137#endif
disti::DisplayObject
Definition: display.h:96
disti::GlsSortedDrawGroup::DrawList
Definition: gls_sorted_draw_group.h:77
disti::GlsSortedDrawGroup::DrawList::deferredDrawList
DeferredDrawListT deferredDrawList
Unused.
Definition: gls_sorted_draw_group.h:90
disti::GlsSortedDrawGroup::DrawList::drawEntryList
EntryListT drawEntryList
List of drawables in sorted order.
Definition: gls_sorted_draw_group.h:88
disti::GlsSortedDrawGroup::DrawList::Optimize
void Optimize()
disti::GlsSortedDrawGroup::DrawList::DeferredDrawListT
std::vector< GlsDeferredDrawGroup * > DeferredDrawListT
Unused.
Definition: gls_sorted_draw_group.h:87
disti::GlsSortedDrawGroup::DrawList::orderPreservedDrawList
EntryListT orderPreservedDrawList
List of drawables in orginal order.
Definition: gls_sorted_draw_group.h:89
disti::GlsSortedDrawGroup::DrawList::Draw
void Draw()
Draw the nodes.
disti::GlsSortedDrawGroup::DrawList::RegisterDrawable
void RegisterDrawable(GlsSortedDrawable *obj)
disti::GlsSortedDrawGroup::DrawList::EntryListT
std::vector< GlsSortedDrawable * > EntryListT
Typedef for a list of drawables.
Definition: gls_sorted_draw_group.h:86
disti::GlsSortedDrawGroup::DrawList::drawEntryListCount
unsigned long drawEntryListCount
Number of elements in the entry list.
Definition: gls_sorted_draw_group.h:91
disti::GlsSortedDrawGroup::DrawList::Clear
void Clear()
Clear the list.
disti::GlsSortedDrawGroup::DrawList::orderPreservedDrawListCount
unsigned long orderPreservedDrawListCount
Number of elements in the original order list.
Definition: gls_sorted_draw_group.h:92
disti::GlsSortedDrawGroup::DrawList::Sort
void Sort()
Sort the list using GlsSortedDrawable::SortedDraw_Compare.
disti::GlsSortedDrawGroup
Definition: gls_sorted_draw_group.h:67
disti::GlsSortedDrawGroup::Draw
virtual void Draw() DISTI_METHOD_OVERRIDE
disti::GlsSortedDrawGroup::_drawList
DrawList _drawList
Holds sorting and object data.
Definition: gls_sorted_draw_group.h:132
disti::GlsSortedDrawGroup::GetActiveDrawListPtr
static DrawList * GetActiveDrawListPtr()
disti::GlsSortedDrawGroup::SetActiveDrawListPtr
static void SetActiveDrawListPtr(DrawList *)
Set the active GlsSortedDrawGroup::DrawList for the calling thread.
disti::GlsSortedDrawGroup::DisableSortedDraw
bool DisableSortedDraw()
disti::GlsSortedDrawGroup::_sortedDrawDisabled
bool _sortedDrawDisabled
If true, draw in original order rather than sorted order.
Definition: gls_sorted_draw_group.h:131
disti::GlsSortedDrawable
Definition: gls_sorted_drawable.h:48
disti::Group
Definition: group.h:53
DISTI_DEPRECATED
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:488
DISTI_METHOD_OVERRIDE
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:222
GLSGEN_GlsAdvancedMesh_EXPORT
#define GLSGEN_GlsAdvancedMesh_EXPORT
Provides support for creating DLLs.
Definition: gls_sorted_draw_group.h:54
gls_sorted_drawable.h
A sorted drawable group.
group.h
The disti::Group class. Implements groups of objects.
disti
Definition: bmpimage.h:47