xoreos  0.0.5
meshquad.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 MeshQuad::MeshQuad() : Mesh(GL_TRIANGLES, GL_STATIC_DRAW) {
32  VertexDecl vertexDecl;
33  vertexDecl.push_back(VertexAttrib(VPOSITION, 3, GL_FLOAT));
34  vertexDecl.push_back(VertexAttrib(VTCOORD, 2, GL_FLOAT));
35  _vertexBuffer.setVertexDeclLinear(6, vertexDecl);
36  float *verts = static_cast<float *>(_vertexBuffer.getData());
37 
38  // Position
39 
40  *verts++ = 1.0f; *verts++ = 1.0f; *verts++ = 0.0f;
41  *verts++ = 0.0f; *verts++ = 1.0f; *verts++ = 0.0f;
42  *verts++ = 0.0f; *verts++ = 0.0f; *verts++ = 0.0f;
43 
44  *verts++ = 0.0f; *verts++ = 0.0f; *verts++ = 0.0f;
45  *verts++ = 1.0f; *verts++ = 0.0f; *verts++ = 0.0f;
46  *verts++ = 1.0f; *verts++ = 1.0f; *verts++ = 0.0f;
47 
48  // Texture coordinates
49 
50  *verts++ = 1.0f; *verts++ = 1.0f;
51  *verts++ = 0.0f; *verts++ = 1.0f;
52  *verts++ = 0.0f; *verts++ = 0.0f;
53 
54  *verts++ = 0.0f; *verts++ = 0.0f;
55  *verts++ = 1.0f; *verts++ = 0.0f;
56  *verts++ = 1.0f; *verts++ = 1.0f;
57 }
58 
59 } // End of namespace Mesh
60 
61 } // End of namespace Graphics
Default quad mesh.
Vertex texture coordinates, VTCOORDi = VTCOORD + i.
Definition: vertexbuffer.h:39
Vertex position.
Definition: vertexbuffer.h:36
std::vector< VertexAttrib > VertexDecl
Vertex data layout.
Definition: vertexbuffer.h:63
void setVertexDeclLinear(uint32 vertCount, VertexDecl &decl)
Set the linear vertex declaration for this buffer.
VertexBuffer _vertexBuffer
Definition: mesh.h:81
GLvoid * getData()
Access buffer data.
Generic vertex attribute data.
Definition: vertexbuffer.h:43