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 
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( void )
59  : _valid( false )
60  , _useList( true )
61  , _handle( 0 )
62  {
63  }
64 
65  GlsDisplayList& operator=( const GlsDisplayList& oldClass )
66  {
67  _useList = oldClass._useList;
68  _valid = false;
69  _handle = 0;
70 
71  return *this;
72  }
73 
74  ~GlsDisplayList( void )
75  {
76  Invalidate();
77  }
78 
79  /** Invalidate the display list. An object with an invalid display list should
80  * reinvoke its draw code to rebuild the display list. Also deallocates the OpenGL list.
81  */
82  void Invalidate( void )
83  {
84  if( _valid )
85  {
86  glDeleteLists( _handle, 1 );
87  _valid = false;
88  _handle = 0;
89  }
90  }
91 
92  /** Allocate an OpenGL display list, deallocating any existing list */
93  void Allocate( void )
94  {
95  Invalidate();
96  _handle = glGenLists( 1 );
97  _valid = true;
98  }
99 
100  /** Start writing into the display list */
101  void Start( void ) { glNewList( _handle, GL_COMPILE ); }
102 
103  /** Stop writing into the display list and save it */
104  void End( void ) { glEndList(); }
105 
106  /** Draw what's in the display list */
107  void Invoke( void ) { glCallList( _handle ); }
108 
109  /** Returns true if the list is valid */
110  bool Valid( void ) { return _valid; }
111 
112  /** Set wether or not the list is valid. Be careful when
113  * setting this to true. Make sure the list really is valid
114  */
115  void Valid( const bool& val ) { _valid = val; }
116 
117  /** Returns true if this display list is enabled */
118  bool UseList( void ) { return _useList; }
119 
120  /** Set whether or not this display list is enabled */
121  void UseList( const bool& val ) { _useList = val; }
122 };
123 
124 } // namespace disti
125 
126 #endif
unsigned int _handle
Definition: gls_display_list.h:55
void Invalidate(void)
Definition: gls_display_list.h:82
Definition: gls_display_list.h:50
void Start(void)
Definition: gls_display_list.h:101
bool _useList
Definition: gls_display_list.h:54
The disti::DisplayObject class and global enumerations.
void UseList(const bool &val)
Definition: gls_display_list.h:121
bool UseList(void)
Definition: gls_display_list.h:118
bool Valid(void)
Definition: gls_display_list.h:110
void Allocate(void)
Definition: gls_display_list.h:93
bool _valid
Definition: gls_display_list.h:53
void End(void)
Definition: gls_display_list.h:104
void Invoke(void)
Definition: gls_display_list.h:107
Definition: bmpimage.h:46
void Valid(const bool &val)
Definition: gls_display_list.h:115