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