Add window utilities
This commit is contained in:
56
include/window.h
Normal file
56
include/window.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#ifndef WINDOW_H
|
||||
#define WINDOW_H
|
||||
|
||||
#include "SDL_pixels.h"
|
||||
#include "aliases/aliases.h"
|
||||
#include <SDL2/SDL_render.h>
|
||||
#include <SDL2/SDL_video.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct point point_t;
|
||||
typedef struct line line_t;
|
||||
typedef struct triangle triangle_t;
|
||||
typedef struct window window_t;
|
||||
|
||||
struct point {
|
||||
i32 x;
|
||||
i32 y;
|
||||
};
|
||||
|
||||
struct line {
|
||||
point_t p0;
|
||||
point_t p1;
|
||||
};
|
||||
|
||||
struct triangle {
|
||||
point_t p0;
|
||||
point_t p1;
|
||||
point_t p2;
|
||||
};
|
||||
|
||||
struct window {
|
||||
u64 width;
|
||||
u64 height;
|
||||
const char *title;
|
||||
SDL_Window *window;
|
||||
SDL_Renderer *renderer;
|
||||
};
|
||||
|
||||
typedef struct colour colour_t;
|
||||
struct colour {
|
||||
union {
|
||||
u32 abgr;
|
||||
SDL_Color colour;
|
||||
};
|
||||
};
|
||||
|
||||
bool init_window(window_t *wnd, const char *title, u64 width, u64 height);
|
||||
void cleanup_window(window_t *wnd);
|
||||
void clear_window(const window_t *wnd, colour_t colour);
|
||||
void swap_buffers(const window_t *wnd);
|
||||
void draw_point(const window_t *wnd, point_t p, colour_t colour);
|
||||
void draw_line(const window_t *wnd, const line_t *ln, colour_t colour);
|
||||
void draw_triangle(const window_t *wnd, const triangle_t *triangle,
|
||||
colour_t colour);
|
||||
|
||||
#endif // !WINDOW_H
|
Reference in New Issue
Block a user