hx3d  1
2D/3D Simple Game Framework
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
cube_geometry.cpp
1 /*
2  Cube model.
3  Copyright (C) 2015 Denis BOURGE
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
21 #include "hx3d/graphics/geometries/cube_geometry.hpp"
22 
23 namespace hx3d {
24 namespace graphics {
25 namespace geom {
26 
27 CubeGeometry::CubeGeometry(): Geometry() {
28 
29  setAttribute("Position", std::vector<float> {
30  -0.5f, -0.5f, -0.5f,
31  0.5f, -0.5f, -0.5f,
32  0.5f, -0.5f, 0.5f,
33  -0.5f, -0.5f, 0.5f,
34 
35  -0.5f, 0.5f, -0.5f,
36  0.5f, 0.5f, -0.5f,
37  0.5f, 0.5f, 0.5f,
38  -0.5f, 0.5f, 0.5f
39  });
40 
41  setIndices(std::vector<GLushort> {
42  0, 1, 5,
43  0, 5, 4,
44  1, 2, 6,
45  1, 6, 5,
46  2, 3, 6,
47  3, 6, 7,
48  0, 3, 7,
49  0, 7, 4,
50  4, 5, 7,
51  5, 7, 6,
52  0, 1, 2,
53  0, 2, 3
54  });
55 
56  setAttribute("Color", std::vector<float> {
57  1, 0, 0, 1,
58  1, 0, 0, 1,
59  1, 0, 0, 1,
60  1, 0, 0, 1,
61 
62  0, 0, 1, 1,
63  0, 0, 1, 1,
64  0, 0, 1, 1,
65  0, 0, 1, 1
66  });
67 
68  uploadAll();
69 }
70 
71 } /* geom */
72 } /* graphics */
73 } /* hx3d */
hx3d framework namespace
Definition: audio.hpp:26
void setIndices(std::vector< GLushort > values)
Set the indices.
void setAttribute(std::string name, std::vector< float > values)
Set an attribute with values.
void uploadAll()
Upload all the buffers to the GPU.