LibCarna Version 3.4.0
Loading...
Searching...
No Matches
IndexBuffer.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010 - 2016 Leonid Kostrykin
3 *
4 * Chair of Medical Engineering (mediTEC)
5 * RWTH Aachen University
6 * Pauwelsstr. 20
7 * 52074 Aachen
8 * Germany
9 *
10 *
11 * Copyright (C) 2021 - 2025 Leonid Kostrykin
12 *
13 */
14
15#ifndef INDEXBUFFER_H_6014714286
16#define INDEXBUFFER_H_6014714286
17
18#include <LibCarna/LibCarna.hpp>
20#include <iterator>
21#include <cstdint>
22
28namespace LibCarna
29{
30
31namespace base
32{
33
34
35
36// ----------------------------------------------------------------------------------
37// IndexBuffer
38// ----------------------------------------------------------------------------------
39
46class LIBCARNA IndexBufferBase : public BaseBuffer
47{
48
49protected:
50
55 void copy( const void* bufferPtr, std::size_t bufferSize, std::size_t indicesCount );
56
57public:
58
59 const static unsigned int TYPE_UINT_8;
60 const static unsigned int TYPE_UINT_16;
61 const static unsigned int TYPE_UINT_32;
62
68 const static unsigned int PRIMITIVE_TYPE_TRIANGLES;
69
75 const static unsigned int PRIMITIVE_TYPE_TRIANGLE_STRIP;
76
81 const static unsigned int PRIMITIVE_TYPE_TRIANGLE_FAN;
82
87 const static unsigned int PRIMITIVE_TYPE_LINES;
88
93 const static unsigned int PRIMITIVE_TYPE_LINE_STRIP;
94
100 const static unsigned int PRIMITIVE_TYPE_LINE_LOOP;
101
105 const static unsigned int PRIMITIVE_TYPE_POINTS;
106
110 const unsigned int type;
111
115 const unsigned int primitiveType;
116
127 IndexBufferBase( unsigned int type, unsigned int primitiveType );
128
129}; // IndexBufferBase
130
131
132
133// ----------------------------------------------------------------------------------
134// IndexBufferTypeMapper
135// ----------------------------------------------------------------------------------
136
140template< typename IndexType >
142{
143 static_assert( sizeof( IndexType ) < 0, "Unknown index type." );
144};
145
146
150template< >
152{
156 operator unsigned int()
157 {
159 }
160};
161
162
166template< >
168{
172 operator unsigned int()
173 {
175 }
176};
177
178
182template< >
184{
188 operator unsigned int()
189 {
191 }
192};
193
194
195
196// ----------------------------------------------------------------------------------
197// IndexBuffer
198// ----------------------------------------------------------------------------------
199
205template< typename IndexType >
207{
208
209public:
210
215
223 IndexBuffer( unsigned int primitiveType );
224
229 void copy( const IndexType* indicesPtr, const std::size_t indicesCount );
230
231}; // IndexBuffer
232
233
234template< typename IndexType >
235IndexBuffer< IndexType >::IndexBuffer( unsigned int primitiveType )
236 : IndexBufferBase( IndexBufferTypeMapper< IndexType >(), primitiveType )
237{
238}
239
240
241template< typename IndexType >
246
247
248
249} // namespace LibCarna :: base
250
251} // namespace LibCarna
252
253#endif // INDEXBUFFER_H_6014714286
Defines LibCarna::base::BaseBuffer.
Contains forward-declarations.
Represents an association.
Implements OpenGL buffer objects maintenance RAII base class.
Maintains GL_ELEMENT_ARRAY_BUFFER object that holds the vertex indices, that interconnect the vertice...
const unsigned int primitiveType
Holds how the indexed vertices do interconnect to primitives.
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...
static const unsigned int PRIMITIVE_TYPE_TRIANGLES
Draws triangles. Indicates that the indices make up the th triangle with .
const unsigned int type
Holds the element type of the maintained OpenGL buffer object.
static const unsigned int PRIMITIVE_TYPE_LINES
Draws lines. Indicates that the indices make up the th line segment with .
static const unsigned int TYPE_UINT_32
Indicates uint32_t element type.
static const unsigned int PRIMITIVE_TYPE_POINTS
Draws points. Indicates that each index makes up a single point.
static const unsigned int PRIMITIVE_TYPE_TRIANGLE_STRIP
Draws triangles. Indicates that the indices make up the th triangle with .
static const unsigned int TYPE_UINT_8
Indicates uint8_t element type.
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 TYPE_UINT_16
Indicates uint16_t element type.
IndexBufferBase(unsigned int type, unsigned int primitiveType)
Creates GL_ELEMENT_ARRAY_BUFFER object.
static const unsigned int PRIMITIVE_TYPE_LINE_STRIP
Draws lines. Indicates that the indices make up a the th line segment with .
static const unsigned int PRIMITIVE_TYPE_TRIANGLE_FAN
Draws triangles. Indicates that the indices make up the th triangle with .
Specializes IndexBufferBase for particular IndexType.
IndexType Index
Holds the index type maintained by this index buffer object.
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.
Maps index buffer element types to descriptive constants.