| GL Studio C++ Runtime API

gls_display_list.h
Go to the documentation of this file.
1/*! \file
2 \brief The disti::GlsDisplayList class.
3
4 \par Copyright Information
5
6 Copyright (c) 2017 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*/
40#ifndef _GLS_DISPLAY_LIST_H
41#define _GLS_DISPLAY_LIST_H
42#include "display.h"
43
44 namespace disti
45{
46/**
47 The GlsDisplayList class. Manages an OpenGL display list.
48*/
49
50 class GlsDisplayList
51{
52 protected:
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
57 public:
58 GlsDisplayList()
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).
68 GlsDisplayList& operator=( const GlsDisplayList& oldClass )
69 {
70 _useList = oldClass._useList;
71 _valid = false;
72 _handle = 0;
73
74 return *this;
75 }
76
77 ~GlsDisplayList()
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 */
85 void Invalidate()
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
disti::GlsDisplayList
Definition: gls_display_list.h:51
disti::GlsDisplayList::Start
void Start()
Definition: gls_display_list.h:104
disti::GlsDisplayList::Valid
void Valid(const bool &val)
Definition: gls_display_list.h:118
disti::GlsDisplayList::Allocate
void Allocate()
Definition: gls_display_list.h:96
disti::GlsDisplayList::UseList
bool UseList()
Definition: gls_display_list.h:121
disti::GlsDisplayList::operator=
GlsDisplayList & operator=(const GlsDisplayList &oldClass)
Definition: gls_display_list.h:68
disti::GlsDisplayList::Valid
bool Valid()
Definition: gls_display_list.h:113
disti::GlsDisplayList::UseList
void UseList(const bool &val)
Definition: gls_display_list.h:125
disti::GlsDisplayList::Invalidate
void Invalidate()
Definition: gls_display_list.h:85
disti::GlsDisplayList::_useList
bool _useList
Definition: gls_display_list.h:54
disti::GlsDisplayList::Invoke
void Invoke()
Definition: gls_display_list.h:110
disti::GlsDisplayList::_valid
bool _valid
Definition: gls_display_list.h:53
disti::GlsDisplayList::_handle
unsigned int _handle
Definition: gls_display_list.h:55
disti::GlsDisplayList::End
void End()
Definition: gls_display_list.h:107
display.h
The disti::DisplayObject class and global enumerations.
disti
Definition: bmpimage.h:47