/* Definition of a mesh of unstructured triangles in the RAM and in the GPU. */ #ifndef cviewer_mesh_H #define cviewer_mesh_H #include #include #include typedef struct mesh_vertex_t { rf3_t vertex; rf3_t normal; } mesh_vertex_t; typedef struct mesh_t { GLuint vao, vbo; rf4x4_t model; rf3_t color; mesh_vertex_t* vertices; GLsizei count; } mesh_t; /* Holds the data from a mesh that exists either in the RAM as in GPU memory */ void mesh_create(mesh_t* m, mesh_vertex_t const* vertices, size_t count); /* Populates a mesh {m} with {count} vertices described by following the pointer {vertices} and upload to the GPU The {vertices} data could be safely freed after calling {mesh_create}. */ void mesh_destroy(mesh_t const* m); /* Destroys all resources created by {m} in the GPU and in memory. */ void mesh_bind(mesh_t const* m); /* Binds the mesh and the buffer to be drawn. */ void mesh_update(mesh_t const* m); /* Updates the vertices in ram to the GPU. */ void mesh_draw(mesh_t const* m); /* Draws the mesh. */ #endif