aboutsummaryrefslogtreecommitdiff
path: root/include/mgl/graphics/vertex_buffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/mgl/graphics/vertex_buffer.h')
-rw-r--r--include/mgl/graphics/vertex_buffer.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/include/mgl/graphics/vertex_buffer.h b/include/mgl/graphics/vertex_buffer.h
new file mode 100644
index 0000000..c1e4af1
--- /dev/null
+++ b/include/mgl/graphics/vertex_buffer.h
@@ -0,0 +1,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, 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, mgl_texture *texture);
+
+#endif /* MGL_VERTEX_BUFFER_H */