GL Studio C++ Runtime API
gls_index_array.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::GlsIndexArray class, for managing index buffers.
3 
4  \par Copyright Information
5 
6  Copyright (c) 2016 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. Use, distribution,
38 duplication, or disclosure by the U. S. Government is subject to
39 "Restricted Rights" as set forth in DFARS 252.227-7014(c)(1)(ii).
40 
41 */
42 
43 #ifndef GLS_INDEX_ARRAY_H
44 #define GLS_INDEX_ARRAY_H
45 
46 #include "gls_include.h"
47 #include "gls_state_manager.h"
48 #include "non_copyable.h"
49 
50 namespace disti
51 {
52 class GlsIndexArray : public NonCopyable
53 {
54 public:
55  /** Default constructor
56  */
57  GlsIndexArray();
58 
59  /** Destructor
60  */
61  virtual ~GlsIndexArray();
62 
63  /** Sets the size of the index buffer
64  * \param size New index buffer count
65  */
66  void SetSize( const unsigned int size );
67 
68  /** \return Returns the size of the index buffer */
69  unsigned int GetSize() const
70  {
71  return _size;
72  }
73 
74  /** Populates the the index buffer
75  * \pre _size > 0
76  * \param indexData The indices to set. The array length is assumed to be equal to GetSize()
77  */
78  void SetIndices( const unsigned short indexData[] );
79 
80  /** Sets one index
81  * \pre index < _size
82  * \param index The index of the index to set
83  * \param val The index data
84  */
85  void SetIndex( const unsigned int index, const unsigned short value );
86 
87  /** Download the index buffer data to Open GL
88  * \pre (_vboHandle != 0) && (_size > 0)
89  * \param stateManager The OpenGL state to download the index buffer to
90  */
91  void Bake( IGlsStateManager* stateManager );
92 
93  /** Bind the index buffer, e.g. make it current
94  * \pre (_vboHandle != 0) && (_size > 0)
95  * \param stateManager The OpenGL state to bind the buffer on
96  */
97  void Bind( IGlsStateManager* stateManager );
98 
99 protected:
100  unsigned short* _indexData; /**< The memory for storing the indices */
101  unsigned int _vboHandle; /**< The OpenGL VBO handle */
102  unsigned int _size; /**< The number of indices. There can be unsigned int quantity of unsigned short values*/
103 
104  /** Allocates the buffer data, copying the existing data
105  * \param size The new size in bytes to allocate
106  */
107  void AllocateBuffer( const unsigned int size );
108 
109  /** Deallocates the buffer data
110  */
111  void DeallocateBuffer();
112 };
113 
114 } // namespace disti
115 
116 #endif
A base class for objects that are not copyable via the standard C++ copy constructor.
void SetSize(const unsigned int size)
void AllocateBuffer(const unsigned int size)
Definition: gls_state_manager_interface.h:67
The disti::GlsStateManager factory class. Creates an instance of a state manager that manages the GL ...
A file for all GL Studio files to include.
void Bake(IGlsStateManager *stateManager)
unsigned int _size
Definition: gls_index_array.h:102
unsigned int _vboHandle
Definition: gls_index_array.h:101
unsigned short * _indexData
Definition: gls_index_array.h:100
void Bind(IGlsStateManager *stateManager)
void SetIndex(const unsigned int index, const unsigned short value)
Definition: gls_index_array.h:52
virtual ~GlsIndexArray()
void SetIndices(const unsigned short indexData[])
Definition: non_copyable.h:45
Definition: bmpimage.h:46
unsigned int GetSize() const
Definition: gls_index_array.h:69