1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#ifndef MGL_VERTEX_BUFFER_H
#define MGL_VERTEX_BUFFER_H
#include "vertex.h"
#include <stddef.h>
typedef struct mgl_context mgl_context;
typedef struct mgl_texture mgl_texture;
typedef enum {
MGL_PRIMITIVE_POINTS,
MGL_PRIMITIVE_LINES,
MGL_PRIMITIVE_LINE_STRIP,
MGL_PRIMITIVE_TRIANGLES,
MGL_PRIMITIVE_TRIANGLE_STRIP,
MGL_PRIMITIVE_TRIANGLE_FAN,
MGL_PRIMITIVE_QUADS,
MGL_PRIMITIVE_QUAD_STRIP,
MGL_PRIMITIVE_POLYGON,
} mgl_primitive_type;
typedef enum {
MGL_USAGE_STREAM,
MGL_USAGE_DYNAMIC,
MGL_USAGE_STATIC
} mgl_vertex_buffer_usage;
typedef struct {
unsigned int id;
size_t vertex_count;
mgl_primitive_type primitive_type;
mgl_vertex_buffer_usage usage;
mgl_vec2f position;
} mgl_vertex_buffer;
int mgl_vertex_buffer_init(mgl_vertex_buffer *self, mgl_primitive_type primitive_type, mgl_vertex_buffer_usage usage);
void mgl_vertex_buffer_deinit(mgl_vertex_buffer *self);
void mgl_vertex_buffer_set_position(mgl_vertex_buffer *self, mgl_vec2f position);
int mgl_vertex_buffer_update(mgl_vertex_buffer *self, const mgl_vertex *vertices, size_t vertex_count);
/* |texture| can be NULL to not use any texture */
void mgl_vertex_buffer_draw(mgl_context *context, mgl_vertex_buffer *self, const mgl_texture *texture);
#endif /* MGL_VERTEX_BUFFER_H */
|