OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mesh.hpp
Go to the documentation of this file.
1 /* Copyright (c) 2014-2017, ARM Limited and Contributors
2  *
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge,
6  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
9  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19  */
20 
21 #ifndef MESH_HPP__
22 #define MESH_HPP__
23 
24 #include <vector>
25 #include <stdint.h>
26 #include "common.hpp"
27 
28 struct Vertex
29 {
30  Vertex() {}
32  : position(position), normal(normal), tex(tex) {}
33 
37 };
38 
39 struct AABB
40 {
43 };
44 
45 struct Mesh
46 {
47  std::vector<Vertex> vbo;
48  std::vector<uint16_t> ibo;
50 };
51 
52 Mesh create_box_mesh(const AABB &aabb);
53 Mesh create_sphere_mesh(float radius, vec3 center, unsigned vertices_per_circumference);
54 
56 {
57  public:
58  GLDrawable(const Mesh &mesh);
59  GLDrawable();
60  ~GLDrawable();
61 
62  const AABB& get_aabb() const;
63 
64  GLuint get_vertex_array() const;
65  unsigned get_num_elements() const;
66 
67  private:
71 
72  unsigned num_elements;
74 };
75 
76 #endif
vec2 tex
Definition: mesh.hpp:36
GLuint vertex_array
Definition: mesh.hpp:68
unsigned get_num_elements() const
Definition: mesh.cpp:112
Vertex(vec3 position, vec3 normal, vec2 tex)
Definition: mesh.hpp:31
Definition: matrix.h:51
Definition: matrix.h:28
AABB aabb
Definition: mesh.hpp:49
unsigned num_elements
Definition: mesh.hpp:72
AABB aabb
Definition: mesh.hpp:73
GLuint vertex_buffer
Definition: mesh.hpp:69
Definition: matrix.h:75
vec4 minpos
Definition: mesh.hpp:41
GLuint get_vertex_array() const
Definition: mesh.cpp:117
Mesh create_box_mesh(const AABB &aabb)
Definition: mesh.cpp:206
vec3 position
Definition: mesh.hpp:34
std::vector< Vertex > vbo
Definition: mesh.hpp:47
Definition: mesh.hpp:28
~GLDrawable()
Definition: mesh.cpp:100
vec3 normal
Definition: mesh.hpp:35
GLuint index_buffer
Definition: mesh.hpp:70
vec4 maxpos
Definition: mesh.hpp:42
Mesh create_sphere_mesh(float radius, vec3 center, unsigned vertices_per_circumference)
Definition: mesh.cpp:122
std::vector< uint16_t > ibo
Definition: mesh.hpp:48
Definition: mesh.hpp:39
GLDrawable()
Definition: mesh.cpp:25
const AABB & get_aabb() const
Definition: mesh.cpp:107
static Mesh * mesh[2]
Definition: ocean.cpp:59
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
Vertex()
Definition: mesh.hpp:30