summaryrefslogtreecommitdiff
path: root/render.h
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-06-01 12:19:16 +1000
committerquou <quou@disroot.org>2024-06-01 12:20:17 +1000
commitea7cd94f7aeb177618db3907a6c86b7252e018f0 (patch)
treee972f9cf590ef756c2e41f3eac5b03e16db08300 /render.h
Initial commit.
Diffstat (limited to 'render.h')
-rw-r--r--render.h140
1 files changed, 140 insertions, 0 deletions
diff --git a/render.h b/render.h
new file mode 100644
index 0000000..62044a0
--- /dev/null
+++ b/render.h
@@ -0,0 +1,140 @@
+#ifndef render_h
+#define render_h
+
+#include "config.h"
+#include "rect.h"
+#include "memory.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 Bitmap {
+ Colour* pixels;
+ int w, h;
+} Bitmap;
+
+void init_bitmap(
+ Bitmap* bitmap,
+ Colour* pixels,
+ int w,
+ int h
+);
+
+#define max_glyphset 256
+
+struct Font;
+typedef struct Font Font;
+
+int font_height(Font* f);
+
+void get_font_rect(
+ const Font* font,
+ Rectangle* dst,
+ char c
+);
+
+Font* new_font(
+ Heap* h,
+ const unsigned char* raw,
+ int size
+);
+Rectangle text_rect(Font* font, const char* text);
+
+void rfont_text(
+ Font* font,
+ int x,
+ int y,
+ const char* text
+);
+void rfont_text_col(
+ Font* font,
+ int x,
+ int y,
+ const char* text,
+ Colour colour
+);
+
+void render_init(void);
+
+void render_begin(void);
+void render_clear(void);
+void render_clear_col(Colour col);
+void render_clip(const Rectangle* rect);
+void render_reset_clip(void);
+
+Colour blend(Colour dst, Colour src);
+Colour blend_mod(Colour dst, Colour src, Colour mod);
+
+Colour* get_render_pixels(void);
+
+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
+);
+
+void render_rect(
+ const Rectangle* rect,
+ Colour colour
+);
+
+void render_mask(
+ const unsigned char* pixels,
+ int x,
+ int y,
+ int w,
+ int h,
+ const Rectangle* rect,
+ Colour colour
+);
+
+void rcopy(
+ Bitmap* dst,
+ const Bitmap* src,
+ int x,
+ int y,
+ const Rectangle* rect
+);
+
+void rcopy_col(
+ Bitmap* dst,
+ const Bitmap* src,
+ int x,
+ int y,
+ const Rectangle* rect,
+ Colour colour
+);
+
+void rcopy_ac(
+ Bitmap* dst,
+ const Bitmap* src,
+ int x,
+ int y,
+ const Rectangle* rect,
+ unsigned char t
+);
+
+void rcopy_rect(
+ Bitmap* dst,
+ const Rectangle* rect,
+ Colour colour
+);
+
+#endif