| 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/// \details The GlsIndexArray class. Wraps an OpenGL index buffer object.
53 class GlsIndexArray : public NonCopyable
54{
55 public:
56 /** Default constructor
57 */
58 GlsIndexArray();
59
60 /** Destructor
61 */
62 virtual ~GlsIndexArray();
63
64 /** Sets the size of the index buffer
65 * \param size New index buffer count
66 */
67 void SetSize( const unsigned int size );
68
69 /** \return Returns the size of the index buffer */
70 unsigned int GetSize() const
71 {
72 return _size;
73 }
74
75 /** Populates the the index buffer
76 * \pre _size > 0
77 * \param indexData The indices to set. The array length is assumed to be equal to GetSize()
78 */
79 void SetIndices( const unsigned short indexData[] );
80
81 /** Sets one index
82 * \pre index < _size
83 * \param index The index of the index to set
84 * \param value The index data
85 */
86 void SetIndex( const unsigned int index, const unsigned short value );
87
88 /** Download the index buffer data to Open GL
89 * \pre (_vboHandle != 0) && (_size > 0)
90 * \param stateManager The OpenGL state to download the index buffer to
91 */
92 void Bake( IGlsStateManager* stateManager );
93
94 /** Bind the index buffer, e.g. make it current
95 * \pre (_vboHandle != 0) && (_size > 0)
96 * \param stateManager The OpenGL state to bind the buffer on
97 */
98 void Bind( IGlsStateManager* stateManager );
99
100 protected:
101 unsigned short* _indexData; /**< The memory for storing the indices */
102 unsigned int _vboHandle; /**< The OpenGL VBO handle */
103 unsigned int _size; /**< The number of indices. There can be unsigned int quantity of unsigned short values*/
104
105 /** Allocates the buffer data, copying the existing data
106 * \param size The new size in bytes to allocate
107 */
108 void AllocateBuffer( const unsigned int size );
109
110 /** Deallocates the buffer data
111 */
112 void DeallocateBuffer();
113};
114
115} // namespace disti
116
117#endif
disti::GlsIndexArray
Definition: gls_index_array.h:54
disti::GlsIndexArray::Bind
void Bind(IGlsStateManager *stateManager)
disti::GlsIndexArray::SetSize
void SetSize(const unsigned int size)
disti::GlsIndexArray::DeallocateBuffer
void DeallocateBuffer()
disti::GlsIndexArray::_indexData
unsigned short * _indexData
Definition: gls_index_array.h:101
disti::GlsIndexArray::GlsIndexArray
GlsIndexArray()
disti::GlsIndexArray::_size
unsigned int _size
Definition: gls_index_array.h:103
disti::GlsIndexArray::SetIndices
void SetIndices(const unsigned short indexData[])
disti::GlsIndexArray::_vboHandle
unsigned int _vboHandle
Definition: gls_index_array.h:102
disti::GlsIndexArray::GetSize
unsigned int GetSize() const
Definition: gls_index_array.h:70
disti::GlsIndexArray::AllocateBuffer
void AllocateBuffer(const unsigned int size)
disti::GlsIndexArray::SetIndex
void SetIndex(const unsigned int index, const unsigned short value)
disti::GlsIndexArray::Bake
void Bake(IGlsStateManager *stateManager)
disti::GlsIndexArray::~GlsIndexArray
virtual ~GlsIndexArray()
disti::IGlsStateManager
Definition: gls_state_manager_interface.h:69
disti::NonCopyable
Definition: non_copyable.h:47
gls_include.h
A file for all GL Studio files to include.
gls_state_manager.h
The disti::GlsStateManager factory class. Creates an instance of a state manager that manages the GL ...
disti
Definition: bmpimage.h:47
non_copyable.h
A base class for objects that are not copyable via the standard C++ copy constructor.