Add rectangle drawing utilities
This commit is contained in:
13
src/window.c
13
src/window.c
@@ -1,7 +1,8 @@
|
||||
#include "window.h"
|
||||
#include "SDL_render.h"
|
||||
#include "SDL_video.h"
|
||||
#include "aliases/aliases.h"
|
||||
#include <SDL2/SDL_rect.h>
|
||||
#include <SDL2/SDL_render.h>
|
||||
#include <SDL2/SDL_video.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
bool init_window(window_t *wnd, const char *title, u64 width, u64 height) {
|
||||
@@ -72,3 +73,11 @@ void draw_triangle(const window_t *wnd, const triangle_t *triangle,
|
||||
draw_line(wnd, &ln1, colour);
|
||||
draw_line(wnd, &ln2, colour);
|
||||
}
|
||||
|
||||
void draw_rect(const window_t *wnd, const rect_t *rect, colour_t colour) {
|
||||
set_colour(wnd, colour);
|
||||
|
||||
SDL_Rect dst = {rect->topleft.x, rect->topleft.y, rect->w, rect->h};
|
||||
|
||||
SDL_RenderDrawRect(wnd->renderer, &dst);
|
||||
}
|
||||
|
Reference in New Issue
Block a user