diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-10-23 01:39:57 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-10-23 01:39:57 +0200 |
commit | 898b8c95f1f904307c02e978b57301cf1cb0560f (patch) | |
tree | d0bf51298967533ffb3ca6565ee309948820cf3f /src/graphics/vertex.c | |
parent | df2e6771c5bf6f09e62f9d6b86d83a2631ea365f (diff) |
Allow rendering vertices directly
Diffstat (limited to 'src/graphics/vertex.c')
-rw-r--r-- | src/graphics/vertex.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/graphics/vertex.c b/src/graphics/vertex.c new file mode 100644 index 0000000..629b421 --- /dev/null +++ b/src/graphics/vertex.c @@ -0,0 +1,13 @@ +#include "../../include/mgl/graphics/vertex.h" +#include "../../include/mgl/mgl.h" + +void mgl_vertices_draw(mgl_context *context, const mgl_vertex *vertices, size_t vertex_count, mgl_primitive_type primitive_type) { + context->gl.glBegin(mgl_primitive_type_to_gl_mode(primitive_type)); + for(size_t i = 0; i < vertex_count; ++i) { + const mgl_vertex *vertex = &vertices[i]; + context->gl.glColor4ub(vertex->color.r, vertex->color.g, vertex->color.b, vertex->color.a); + context->gl.glTexCoord2f(vertex->texcoords.x, vertex->texcoords.y); + context->gl.glVertex3f(vertex->position.x, vertex->position.y, 0.0f); + } + context->gl.glEnd(); +} |