aboutsummaryrefslogtreecommitdiff
path: root/render.h
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2023-05-02 21:02:04 +1000
committerquou <quou@disroot.org>2023-05-02 21:02:04 +1000
commitc1efdf9b0875f2a39488a86cd838947a24fab9fc (patch)
treeb459d024fa99029758f8d2f8630470fe6060122e /render.h
Initial commit.
Diffstat (limited to 'render.h')
-rw-r--r--render.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/render.h b/render.h
new file mode 100644
index 0000000..d63297e
--- /dev/null
+++ b/render.h
@@ -0,0 +1,79 @@
+#ifndef render_h
+#define render_h
+
+#include "config.h"
+#include "rect.h"
+
+typedef struct {
+ unsigned char r, g, b, a;
+} Colour;
+
+Colour make_colour(unsigned rgb, unsigned char a);
+Colour make_black();
+Colour make_white();
+
+typedef struct {
+ Colour* pixels;
+ int w, h;
+} Bitmap;
+
+void init_bitmap(
+ Bitmap* bitmap,
+ Colour* pixels,
+ int w,
+ int h
+);
+
+typedef struct {
+ Bitmap* bmp;
+ int char_w, char_h;
+ int chars_across;
+} BM_Font;
+
+void init_font(
+ BM_Font* font,
+ Bitmap* bmp,
+ int char_w,
+ int char_h,
+ int chars_across
+);
+
+void rfont_char(int x, int y, char c);
+void rfont_char_col(int x, int y, char c, Colour colour);
+void rfont_text(
+ int x,
+ int y,
+ const char* text
+);
+void rfont_text_col(
+ int x,
+ int y,
+ const char* text,
+ Colour colour
+);
+
+void init_renderer();
+
+void renderer_begin_frame();
+
+Colour* get_render_pixels();
+
+extern int sprite_camera_x;
+extern int sprite_camera_y;
+
+void render_bitmap(
+ const Bitmap* bitmap,
+ int x,
+ int y,
+ const Rectangle* rect
+);
+
+void render_bitmap_col(
+ const Bitmap* bitmap,
+ int x,
+ int y,
+ const Rectangle* rect,
+ Colour colour
+);
+
+#endif