GL Studio C++ Runtime API
gls_display_list.h
Go to the documentation of this file.
1/// \file gls_display_list.h
2/// \brief The disti::GlsDisplayList class.
3///
4/// \par Copyright Information
5///
6/// Copyright (c) 2017 by The DiSTI Corporation.<br>
7/// 12249 Science Drive; Suite 300<br>
8/// Orlando, Florida 32826<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 DISTI_INCLUDED_GLS_DISPLAY_LIST_H
40#define DISTI_INCLUDED_GLS_DISPLAY_LIST_H
41
42#include "display.h"
43
44namespace disti
45{
46/**
47 The GlsDisplayList class. Manages an OpenGL display list.
48*/
49
51{
52protected:
53 bool _valid; /**< True if this list is valid */
54 bool _useList; /**< True if this list is enabled */
55 unsigned int _handle; /**< The OpenGL list handle for this list */
56
57public:
59 : _valid( false )
60 , _useList( true )
61 , _handle( 0 )
62 {
63 }
64
65 /// Assignment operator
66 /// \param oldClass The list to copy from.
67 /// \return The resulting list (this).
69 {
70 _useList = oldClass._useList;
71 _valid = false;
72 _handle = 0;
73
74 return *this;
75 }
76
78 {
79 Invalidate();
80 }
81
82 /** Invalidate the display list. An object with an invalid display list should
83 * reinvoke its draw code to rebuild the display list. Also deallocates the OpenGL list.
84 */
86 {
87 if( _valid )
88 {
89 glDeleteLists( _handle, 1 );
90 _valid = false;
91 _handle = 0;
92 }
93 }
94
95 /** Allocate an OpenGL display list, deallocating any existing list */
96 void Allocate()
97 {
98 Invalidate();
99 _handle = glGenLists( 1 );
100 _valid = true;
101 }
102
103 /** Start writing into the display list */
104 void Start() { glNewList( _handle, GL_COMPILE ); }
105
106 /** Stop writing into the display list and save it */
107 void End() { glEndList(); }
108
109 /** Draw what's in the display list */
110 void Invoke() { glCallList( _handle ); }
111
112 /// \returns true if the list is valid
113 bool Valid() { return _valid; }
114
115 /// Set whether or not the list is valid.
116 /// \note Be careful when setting this to true. Make sure the list really is valid.
117 /// \param val The new validity of the list.
118 void Valid( const bool& val ) { _valid = val; }
119
120 /// \return True if this display list is enabled.
121 bool UseList() { return _useList; }
122
123 /// Set whether or not this display list is enabled.
124 /// \param val The new enabled state of the list.
125 void UseList( const bool& val ) { _useList = val; }
126};
127
128} // namespace disti
129
130#endif
Definition: gls_display_list.h:51
void Start()
Definition: gls_display_list.h:104
void Valid(const bool &val)
Definition: gls_display_list.h:118
void Allocate()
Definition: gls_display_list.h:96
bool UseList()
Definition: gls_display_list.h:121
GlsDisplayList & operator=(const GlsDisplayList &oldClass)
Definition: gls_display_list.h:68
bool Valid()
Definition: gls_display_list.h:113
void UseList(const bool &val)
Definition: gls_display_list.h:125
void Invalidate()
Definition: gls_display_list.h:85
bool _useList
Definition: gls_display_list.h:54
void Invoke()
Definition: gls_display_list.h:110
bool _valid
Definition: gls_display_list.h:53
unsigned int _handle
Definition: gls_display_list.h:55
void End()
Definition: gls_display_list.h:107
The disti::DisplayObject class and global enumerations.
Definition: bmpimage.h:46