aboutsummaryrefslogtreecommitdiff
path: root/src/graphics/rectangle.c
blob: de721b70ec7ffe926756eb9f1209c5eeb5004fab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "../../include/mgl/graphics/rectangle.h"
#include "../../include/mgl/mgl.h"
#include "../../include/mgl/window/window.h"

void mgl_rectangle_draw(mgl_context *context, const mgl_rectangle *rect) {
    mgl_window_set_texture_blend_func(context->current_window);

    context->gl.glColor4ub(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();

    mgl_window_set_render_blend_func(context->current_window);
}