From 97f1b1c735775d1e22412bbcf98ef403f9ee2275 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 16 Oct 2021 07:04:34 +0200 Subject: Add rectangle and sprite, use pixel coordinates, remote opengl dependency from test --- src/graphics/rectangle.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/graphics/rectangle.c (limited to 'src/graphics/rectangle.c') diff --git a/src/graphics/rectangle.c b/src/graphics/rectangle.c new file mode 100644 index 0000000..4f2e40b --- /dev/null +++ b/src/graphics/rectangle.c @@ -0,0 +1,12 @@ +#include "../../include/mgl/graphics/rectangle.h" +#include "../../include/mgl/mgl.h" + +void mgl_rectangle_draw(mgl_context *context, mgl_rectangle *rect) { + context->gl.glColor4f(rect->color.r, rect->color.g, rect->color.b, rect->color.a); + context->gl.glBegin(GL_QUADS); + context->gl.glVertex3f(rect->position.x, rect->position.y, 0.0f); + context->gl.glVertex3f(rect->position.x + rect->size.x, rect->position.y, 0.0f); + context->gl.glVertex3f(rect->position.x + rect->size.x, rect->position.y + rect->size.y, 0.0f); + context->gl.glVertex3f(rect->position.x, rect->position.y + rect->size.y, 0.0f); + context->gl.glEnd(); +} -- cgit v1.2.3