Carna Version 3.3.3
Loading...
Searching...
No Matches
IndexBuffer.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010 - 2015 Leonid Kostrykin
3 *
4 * Chair of Medical Engineering (mediTEC)
5 * RWTH Aachen University
6 * Pauwelsstr. 20
7 * 52074 Aachen
8 * Germany
9 *
10 */
11
12#ifndef INDEXBUFFER_H_6014714286
13#define INDEXBUFFER_H_6014714286
14
15#include <Carna/Carna.h>
17#include <iterator>
18#include <cstdint>
19
24namespace Carna
25{
26
27namespace base
28{
29
30
31
32// ----------------------------------------------------------------------------------
33// IndexBuffer
34// ----------------------------------------------------------------------------------
35
43class CARNA_LIB IndexBufferBase : public BaseBuffer
44{
45
46protected:
47
52 void copy( const void* bufferPtr, std::size_t bufferSize, std::size_t indicesCount );
53
54public:
55
56 const static unsigned int TYPE_UINT_8;
57 const static unsigned int TYPE_UINT_16;
58 const static unsigned int TYPE_UINT_32;
59
65 const static unsigned int PRIMITIVE_TYPE_TRIANGLES;
66
72 const static unsigned int PRIMITIVE_TYPE_TRIANGLE_STRIP;
73
78 const static unsigned int PRIMITIVE_TYPE_TRIANGLE_FAN;
79
84 const static unsigned int PRIMITIVE_TYPE_LINES;
85
90 const static unsigned int PRIMITIVE_TYPE_LINE_STRIP;
91
97 const static unsigned int PRIMITIVE_TYPE_LINE_LOOP;
98
102 const static unsigned int PRIMITIVE_TYPE_POINTS;
103
107 const unsigned int type;
108
112 const unsigned int primitiveType;
113
124 IndexBufferBase( unsigned int type, unsigned int primitiveType );
125
126}; // IndexBufferBase
127
128
129
130// ----------------------------------------------------------------------------------
131// IndexBufferTypeMapper
132// ----------------------------------------------------------------------------------
133
137template< typename IndexType >
139{
140 static_assert( sizeof( IndexType ) < 0, "Unknown index type." );
141};
142
143
147template< >
149{
153 operator unsigned int()
154 {
156 }
157};
158
159
163template< >
165{
169 operator unsigned int()
170 {
172 }
173};
174
175
179template< >
181{
185 operator unsigned int()
186 {
188 }
189};
190
191
192
193// ----------------------------------------------------------------------------------
194// IndexBuffer
195// ----------------------------------------------------------------------------------
196
203template< typename IndexType >
205{
206
207public:
208
213
221 IndexBuffer( unsigned int primitiveType );
222
227 void copy( const IndexType* indicesPtr, const std::size_t indicesCount );
228
229}; // IndexBuffer
230
231
232template< typename IndexType >
233IndexBuffer< IndexType >::IndexBuffer( unsigned int primitiveType )
234 : IndexBufferBase( IndexBufferTypeMapper< IndexType >(), primitiveType )
235{
236}
237
238
239template< typename IndexType >
244
245
246
247} // namespace Carna :: base
248
249} // namespace Carna
250
251#endif // INDEXBUFFER_H_6014714286
Defines Carna::base::BaseBuffer.
Represents an association.
Definition Association.h:45
Implements OpenGL buffer objects maintenance RAII base class.
Definition BaseBuffer.h:40
Maintains GL_ELEMENT_ARRAY_BUFFER object that holds the vertex indices, that interconnect the vertice...
Definition IndexBuffer.h:44
static const unsigned int TYPE_UINT_32
Indicates uint32_t element type.
Definition IndexBuffer.h:58
static const unsigned int TYPE_UINT_16
Indicates uint16_t element type.
Definition IndexBuffer.h:57
static const unsigned int PRIMITIVE_TYPE_LINE_LOOP
Draws lines. Indicates that the indices make up the th line segment. Another line segment from the l...
Definition IndexBuffer.h:97
static const unsigned int PRIMITIVE_TYPE_LINES
Draws lines. Indicates that the indices make up the th line segment with .
Definition IndexBuffer.h:84
static const unsigned int PRIMITIVE_TYPE_TRIANGLE_STRIP
Draws triangles. Indicates that the indices make up the th triangle with .
Definition IndexBuffer.h:72
static const unsigned int TYPE_UINT_8
Indicates uint8_t element type.
Definition IndexBuffer.h:56
static const unsigned int PRIMITIVE_TYPE_POINTS
Draws points. Indicates that each index makes up a single point.
void copy(const void *bufferPtr, std::size_t bufferSize, std::size_t indicesCount)
Copies indicesCount indices referenced by bufferPtr to the maintained index buffer object.
static const unsigned int PRIMITIVE_TYPE_TRIANGLES
Draws triangles. Indicates that the indices make up the th triangle with .
Definition IndexBuffer.h:65
IndexBufferBase(unsigned int type, unsigned int primitiveType)
Creates GL_ELEMENT_ARRAY_BUFFER object.
const unsigned int type
Holds the element type of the maintained OpenGL buffer object.
static const unsigned int PRIMITIVE_TYPE_LINE_STRIP
Draws lines. Indicates that the indices make up a the th line segment with .
Definition IndexBuffer.h:90
const unsigned int primitiveType
Holds how the indexed vertices do interconnect to primitives.
static const unsigned int PRIMITIVE_TYPE_TRIANGLE_FAN
Draws triangles. Indicates that the indices make up the th triangle with .
Definition IndexBuffer.h:78
Specializes IndexBufferBase for particular IndexType.
IndexBuffer(unsigned int primitiveType)
Creates GL_ELEMENT_ARRAY_BUFFER object.
void copy(const IndexType *indicesPtr, const std::size_t indicesCount)
Copies indicesCount indices referenced by indicesPtr to the maintained index buffer object.
IndexType Index
Holds the index type maintained by this index buffer object.
Maps index buffer element types to descriptive constants.