LibCarna Version 3.4.0
Loading...
Searching...
No Matches
Mesh.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 MESH_H_6014714286
16#define MESH_H_6014714286
17
21#include <memory>
22
28namespace LibCarna
29{
30
31namespace base
32{
33
34
35
36// ----------------------------------------------------------------------------------
37// MeshBase
38// ----------------------------------------------------------------------------------
39
66class LIBCARNA MeshBase
67{
68
69 const std::unique_ptr< Association< VertexBufferBase > > myVertexBuffer;
70 const std::unique_ptr< Association< IndexBufferBase > > myIndexBuffer;
71
72public:
73
79 ( const VertexAttributes& va
81 , Association< IndexBufferBase >* indexBuffer );
82
87 virtual ~MeshBase() noexcept( false );
88
92 const unsigned int id;
93
97 const GLContext& glContext;
98
103 void bind() const;
104
109 void render() const;
110
111 const VertexBufferBase& vertexBuffer() const;
112 const IndexBufferBase& indexBuffer() const;
113
114 VertexBufferBase& vertexBuffer();
115 IndexBufferBase& indexBuffer();
116
117}; // MeshBase
118
119
120
121// ----------------------------------------------------------------------------------
122// Mesh
123// ----------------------------------------------------------------------------------
124
138{
139
140public:
141
146 , Association< IndexBufferBase >* indexBuffer );
147
149 typedef IndexType Index;
150
151}; // Mesh
152
153
154template< typename VertexType, typename IndexType >
156 ( Association< VertexBufferBase >* vertexBuffer
157 , Association< IndexBufferBase >* indexBuffer )
158 : MeshBase( VertexType::attributes, vertexBuffer, indexBuffer )
159{
160}
161
162
163
164} // namespace LibCarna :: base
165
166} // namespace LibCarna
167
168#endif // MESH_H_6014714286
Defines LibCarna::base::IndexBuffer.
Defines LibCarna::base::VertexAttributes.
Defines LibCarna::base::VertexBuffer.
Represents an association.
Wraps and represents an OpenGL context.
Definition GLContext.hpp:66
Maintains GL_ELEMENT_ARRAY_BUFFER object that holds the vertex indices, that interconnect the vertice...
Format-independent abstract Mesh base class. Each mesh consists of a VertexBuffer,...
Definition Mesh.hpp:67
MeshBase(const VertexAttributes &va, Association< VertexBufferBase > *vertexBuffer, Association< IndexBufferBase > *indexBuffer)
virtual ~MeshBase() noexcept(false)
Deletes.
Implements MeshBase class for particular VertexType and IndexType.
Definition Mesh.hpp:138
VertexType Vertex
Holds the element type of the vertex buffer.
Definition Mesh.hpp:148
IndexType Index
Holds the element type of the index buffer.
Definition Mesh.hpp:149
Maintains GL_ARRAY_BUFFER object that holds vertices. This class realizes the RAII-idiom.
std::vector< VertexAttribute > VertexAttributes
Defines VertexAttribute vector.