xoreos  0.0.5
meshwirebox.cpp
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 
26 
27 namespace Graphics {
28 
29 namespace Mesh {
30 
31 MeshWireBox::MeshWireBox() : Mesh(GL_LINES, GL_STATIC_DRAW) {
32  _vertexBuffer.setSize(24, 3 * sizeof(float));
33  float *verts = static_cast<float *>(_vertexBuffer.getData());
34 
35  // TODO: maybe VertexBuffer should allow direct VertexDecl access.
36  VertexDecl decl(1);
37  decl[0].pointer = verts;
38  decl[0].stride = 0;
39  decl[0].type = GL_FLOAT;
40  decl[0].size = 3;
41  decl[0].index = VPOSITION;
43 
44  // Front
45  *verts++ = -1.0f; *verts++ = 1.0f; *verts++ = 1.0f;
46  *verts++ = -1.0f; *verts++ = -1.0f; *verts++ = 1.0f;
47 
48  *verts++ = -1.0f; *verts++ = -1.0f; *verts++ = 1.0f;
49  *verts++ = 1.0f; *verts++ = -1.0f; *verts++ = 1.0f;
50 
51  *verts++ = 1.0f; *verts++ = -1.0f; *verts++ = 1.0f;
52  *verts++ = 1.0f; *verts++ = 1.0f; *verts++ = 1.0f;
53 
54  *verts++ = 1.0f; *verts++ = 1.0f; *verts++ = 1.0f;
55  *verts++ = -1.0f; *verts++ = 1.0f; *verts++ = 1.0f;
56 
57  // Back
58  *verts++ = -1.0f; *verts++ = 1.0f; *verts++ = -1.0f;
59  *verts++ = -1.0f; *verts++ = -1.0f; *verts++ = -1.0f;
60 
61  *verts++ = -1.0f; *verts++ = -1.0f; *verts++ = -1.0f;
62  *verts++ = 1.0f; *verts++ = -1.0f; *verts++ = -1.0f;
63 
64  *verts++ = 1.0f; *verts++ = -1.0f; *verts++ = -1.0f;
65  *verts++ = 1.0f; *verts++ = 1.0f; *verts++ = -1.0f;
66 
67  *verts++ = 1.0f; *verts++ = 1.0f; *verts++ = -1.0f;
68  *verts++ = -1.0f; *verts++ = 1.0f; *verts++ = -1.0f;
69 
70  // Sides
71  *verts++ = -1.0f; *verts++ = 1.0f; *verts++ = 1.0f;
72  *verts++ = -1.0f; *verts++ = 1.0f; *verts++ = -1.0f;
73 
74  *verts++ = -1.0f; *verts++ = -1.0f; *verts++ = 1.0f;
75  *verts++ = -1.0f; *verts++ = -1.0f; *verts++ = -1.0f;
76 
77  *verts++ = 1.0f; *verts++ = -1.0f; *verts++ = 1.0f;
78  *verts++ = 1.0f; *verts++ = -1.0f; *verts++ = -1.0f;
79 
80  *verts++ = 1.0f; *verts++ = 1.0f; *verts++ = 1.0f;
81  *verts++ = 1.0f; *verts++ = 1.0f; *verts++ = -1.0f;
82 }
83 
85 }
86 
87 } // End of namespace Mesh
88 
89 } // End of namespace Graphics
Wireframe box mesh.
Vertex position.
Definition: vertexbuffer.h:36
void setVertexDecl(const VertexDecl &decl)
Set vertex declaration for this buffer.
std::vector< VertexAttrib > VertexDecl
Vertex data layout.
Definition: vertexbuffer.h:63
VertexBuffer _vertexBuffer
Definition: mesh.h:81
GLvoid * getData()
Access buffer data.
void setSize(uint32 vertCount, uint32 vertSize)
Change buffer size.