src/ascension/mesh.h

changeset 115
e5f8c99b0987
parent 82
4e1e698f4b0d
child 116
bfb2a7d62047
equal deleted inserted replaced
114:5b91bbab1ac0 115:e5f8c99b0987
26 */ 26 */
27 27
28 #ifndef ASCENSION_MESH_H 28 #ifndef ASCENSION_MESH_H
29 #define ASCENSION_MESH_H 29 #define ASCENSION_MESH_H
30 30
31 #include "datatypes.h"
32
33 enum AscMeshType {
34 ASC_MESH_2D,
35 ASC_MESH_2D_COLORED,
36 ASC_MESH_3D,
37 ASC_MESH_3D_COLORED,
38 };
39
31 typedef struct AscMesh { 40 typedef struct AscMesh {
41 // TODO: for batched rendering, VAO and VBO must not be part of the mesh
32 unsigned vbo; 42 unsigned vbo;
33 unsigned vao; 43 unsigned vao;
34 unsigned vertices; 44 enum AscMeshType type;
45 unsigned vtx_count;
46 float *vtx_data;
35 } AscMesh; 47 } AscMesh;
48
49 typedef struct AscMeshVertex2d {
50 asc_vec2f pos;
51 asc_vec2f uv;
52 } AscMeshVertex2d;
53
54 typedef struct AscMeshVertex2dColored {
55 asc_vec2f pos;
56 asc_vec2f uv;
57 asc_col4f color;
58 } AscMeshVertex2dColored;
59
60 typedef struct AscMeshVertex3d {
61 asc_vec3f pos;
62 asc_vec2f uv;
63 } AscMeshVertex3d;
64
65 typedef struct AscMeshVertex3dColored {
66 asc_vec3f pos;
67 asc_vec2f uv;
68 asc_col4f color;
69 } AscMeshVertex3dColored;
70
71
72 void asc_mesh_destroy(AscMesh *mesh);
73
74
75 /**
76 * Creates a 2D plane.
77 *
78 * @param mesh the mesh to initialize
79 */
80 void asc_mesh_plane_2d(AscMesh *mesh);
81
82
83
84 // TODO: replace below functions with a batched rendering implementation
36 85
37 /** 86 /**
38 * Allocates VBO and VAO for one or more meshes. 87 * Allocates VBO and VAO for one or more meshes.
39 * 88 *
40 * @param mesh pointer to a mesh or an array of meshes 89 * @param mesh pointer to a mesh or an array of meshes
53 /** 102 /**
54 * Draws the mesh as a triangle strip. 103 * Draws the mesh as a triangle strip.
55 * 104 *
56 * @param mesh the mesh to draw 105 * @param mesh the mesh to draw
57 */ 106 */
58 void asc_mesh_draw_triangle_strip(AscMesh *mesh); 107 void asc_mesh_draw_triangle_strip(const AscMesh *mesh);
59 108
60 #endif //ASCENSION_MESH_H 109 #endif //ASCENSION_MESH_H

mercurial