Carna Version 3.3.3
Loading...
Searching...
No Matches
Mesh.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 MESH_H_6014714286
13#define MESH_H_6014714286
14
18#include <memory>
19
24namespace Carna
25{
26
27namespace base
28{
29
30
31
32// ----------------------------------------------------------------------------------
33// MeshBase
34// ----------------------------------------------------------------------------------
35
63class CARNA_LIB MeshBase
64{
65
66 const std::unique_ptr< Association< VertexBufferBase > > myVertexBuffer;
67 const std::unique_ptr< Association< IndexBufferBase > > myIndexBuffer;
68
69public:
70
76 ( const VertexAttributes& va
78 , Association< IndexBufferBase >* indexBuffer );
79
84 virtual ~MeshBase();
85
89 const unsigned int id;
90
95
100 void bind() const;
101
106 void render() const;
107
110
113
114}; // MeshBase
115
116
117
118// ----------------------------------------------------------------------------------
119// Mesh
120// ----------------------------------------------------------------------------------
121
134template< typename VertexType, typename IndexType >
135class Mesh : public MeshBase
136{
137
138public:
139
145
147 typedef IndexType Index;
148
149}; // Mesh
150
151
152template< typename VertexType, typename IndexType >
154 ( Association< VertexBufferBase >* vertexBuffer
155 , Association< IndexBufferBase >* indexBuffer )
156 : MeshBase( VertexType::attributes, vertexBuffer, indexBuffer )
157{
158}
159
160
161
162} // namespace Carna :: base
163
164} // namespace Carna
165
166#endif // MESH_H_6014714286
Defines Carna::base::IndexBuffer.
Defines Carna::base::VertexAttributes.
Defines Carna::base::VertexBuffer.
Represents an association.
Definition Association.h:45
Wraps and represents an OpenGL context.
Definition GLContext.h:63
Maintains GL_ELEMENT_ARRAY_BUFFER object that holds the vertex indices, that interconnect the vertice...
Definition IndexBuffer.h:44
Format-independent abstract Mesh base class. Each mesh consists of a VertexBuffer,...
Definition Mesh.h:64
virtual ~MeshBase()
Deletes.
const unsigned int id
Holds the ID of the OpenGL vertex array object.
Definition Mesh.h:89
VertexBufferBase & vertexBuffer()
References the mesh's vertex buffer.
MeshBase(const VertexAttributes &va, Association< VertexBufferBase > *vertexBuffer, Association< IndexBufferBase > *indexBuffer)
const VertexBufferBase & vertexBuffer() const
References the mesh's vertex buffer.
void render() const
Renders the mesh.
const GLContext & glContext
References the OpenGL context this mesh is valid within.
Definition Mesh.h:94
IndexBufferBase & indexBuffer()
References the mesh's index buffer.
void bind() const
Binds the vertex array object.
const IndexBufferBase & indexBuffer() const
References the mesh's index buffer.
Implements MeshBase class for particular VertexType and IndexType.
Definition Mesh.h:136
Mesh(Association< VertexBufferBase > *vertexBuffer, Association< IndexBufferBase > *indexBuffer)
Definition Mesh.h:154
IndexType Index
Holds the element type of the index buffer.
Definition Mesh.h:147
VertexType Vertex
Holds the element type of the vertex buffer.
Definition Mesh.h:146
Maintains GL_ARRAY_BUFFER object that holds vertices. This class realizes the RAII-idiom.
std::vector< VertexAttribute > VertexAttributes
Defines VertexAttribute vector.