xoreos  0.0.5
mesh.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef GRAPHICS_MESH_MESH_H
26 #define GRAPHICS_MESH_MESH_H
27 
28 #include "src/common/ustring.h"
29 #include "src/common/mutex.h"
30 
31 #include "src/graphics/graphics.h"
35 
36 namespace Graphics {
37 
38 namespace Mesh {
39 
40 class Mesh : public GLContainer {
41 public:
42  Mesh(GLuint type = GL_TRIANGLES, GLuint hint = GL_STATIC_DRAW);
43  ~Mesh();
44 
47 
48  void setName(const Common::UString &name);
49  const Common::UString &getName() const;
50 
51  void setType(GLuint type);
52  GLuint getType() const;
53 
54  void setHint(GLuint hint);
55  GLuint getHint() const;
56 
58  void init();
59 
60  void initGL();
61  void updateGL();
62  void destroyGL();
63 
64  void renderImmediate();
65 
67  void renderBind();
68  void render();
69  void renderUnbind();
70 
71  void useIncrement();
72  void useDecrement();
73  uint32 useCount() const;
74 
75  const glm::vec3 &getCentre() const;
76 
77  float getRadius() const;
78 
79 protected:
80  // For each attrib, when calculating VBOs, do (attrib address) - (base data address) to find initial data offset.
83 
85  virtual void doRebuild();
86 
88  virtual void doDestroy();
89 
90  GLuint _type;
91  GLuint _hint;
92 
93 private:
96 
97  GLuint _vao;
98 
99  glm::vec3 _centre;
100  glm::vec3 _max;
101  glm::vec3 _min;
102  float _radius;
103 };
104 
105 } // End of namespace Mesh
106 
107 } // End of namespace Graphics
108 
109 #endif // GRAPHICS_MESH_MESH_H
GLuint _hint
Definition: mesh.h:91
glm::vec3 _max
Definition: mesh.h:100
GLuint _type
Definition: mesh.h:90
uint32 _usageCount
Definition: mesh.h:95
The global graphics manager.
void setHint(GLuint hint)
Definition: mesh.cpp:63
const Common::UString & getName() const
Definition: mesh.cpp:51
A class holding an UTF-8 string.
Definition: ustring.h:48
VertexBuffer * getVertexBuffer()
Definition: mesh.cpp:39
void init()
General mesh initialisation, queuing the mesh for GL resource creation.
Definition: mesh.cpp:71
IndexBuffer _indexBuffer
Definition: mesh.h:82
A index buffer.
A container of OpenGL elements.
void setType(GLuint type)
Definition: mesh.cpp:55
float getRadius() const
Definition: mesh.cpp:272
void renderUnbind()
Definition: mesh.cpp:227
Buffer containing vertex data.
Definition: vertexbuffer.h:68
glm::vec3 _centre
Definition: mesh.h:99
void renderImmediate()
Definition: mesh.cpp:171
GLuint getType() const
Definition: mesh.cpp:59
void renderBind()
Follows the steps of renderImmediate, but broken into different functions.
Definition: mesh.cpp:177
VertexBuffer _vertexBuffer
Definition: mesh.h:81
const glm::vec3 & getCentre() const
Definition: mesh.cpp:268
virtual void doRebuild()
Initialise GL components with data taken from vertex buffers.
Definition: mesh.cpp:276
Unicode string handling.
Thread mutex classes.
glm::vec3 _min
Definition: mesh.h:101
uint32_t uint32
Definition: types.h:204
virtual void doDestroy()
Free GL resources.
Definition: mesh.cpp:285
A container of OpenGL elements.
Definition: glcontainer.h:35
Common::UString _name
Definition: mesh.h:94
GLuint getHint() const
Definition: mesh.cpp:67
Buffer containing indices data.
Definition: indexbuffer.h:33
void setName(const Common::UString &name)
Definition: mesh.cpp:47
void useIncrement()
Definition: mesh.cpp:254
IndexBuffer * getIndexBuffer()
Definition: mesh.cpp:43
A vertex buffer.
uint32 useCount() const
Definition: mesh.cpp:264
Mesh(GLuint type=GL_TRIANGLES, GLuint hint=GL_STATIC_DRAW)
Definition: mesh.cpp:31
GLuint _vao
Vertex Array Object handle. GL3.x only.
Definition: mesh.h:97
void useDecrement()
Definition: mesh.cpp:258