summaryrefslogtreecommitdiff
path: root/graphics.c
diff options
context:
space:
mode:
Diffstat (limited to 'graphics.c')
-rw-r--r--graphics.c61
1 files changed, 8 insertions, 53 deletions
diff --git a/graphics.c b/graphics.c
index 3552792..a962ba6 100644
--- a/graphics.c
+++ b/graphics.c
@@ -166,7 +166,7 @@ typedef struct {
Box font_text_area_dispatch(i32 font, vec2 scale, i64 num_chars, c32 *text);
-void font_render_to_buffer_dispatch(Pixel_Buffer dst, i32 font, vec4_f32 color, vec2 position, vec2 scale, i64 num_chars, c32 *text);
+void font_render_to_stencil_dispatch(Stencil_Buffer dst, i32 font, vec2 position, vec2 scale, i64 num_chars, c32 *text);
// ================================================================
@@ -256,56 +256,6 @@ enum {
CHAR_NUM_BITS_ = CHAR_NUM_BITS_X_ * CHAR_NUM_BITS_Y_,
};
-static i64 min2_i64_(i64 x, i64 y) {
- return x < y ? x : y;
-}
-
-static f32 max2_f32_(f32 a, f32 b) {
- return a < b ? b : a;
-}
-
-static f64 min3_(f64 a, f64 b, f64 c) {
- if (a < b && a < c)
- return a;
- if (b < c)
- return b;
- return c;
-}
-
-static f64 max3_(f64 a, f64 b, f64 c) {
- if (a > b && a > c)
- return a;
- if (b > c)
- return b;
- return c;
-}
-
-static f64 min4_(f64 a, f64 b, f64 c, f64 d) {
- if (a < b && a < c && a < d)
- return a;
- if (b < c && b < d)
- return b;
- if (c < d)
- return c;
- return d;
-}
-
-static f64 max4_(f64 a, f64 b, f64 c, f64 d) {
- if (a > b && a > c && a > d)
- return a;
- if (b > c && b > d)
- return b;
- if (c > d)
- return c;
- return d;
-}
-
-static b8 same_sign_(f64 a, f64 b) {
- if (a >= EPSILON && b <= -EPSILON) return 0;
- if (a <= -EPSILON && b >= EPSILON) return 0;
- return 1;
-}
-
static void put_pixel_(vec4_f32 *dst, vec4_f32 color) {
if (color.w == 1.f)
*dst = color;
@@ -826,12 +776,11 @@ Box font_text_area_dispatch(i32 font, vec2 scale, i64 num_chars, c32 *text) {
return (Box) {0};
}
-void font_render_to_buffer_dispatch(Pixel_Buffer dst, i32 font, vec4_f32 color, vec2 position, vec2 scale, i64 num_chars, c32 *text) {
+void font_render_to_stencil_dispatch(Stencil_Buffer dst, i32 font, vec2 position, vec2 scale, i64 num_chars, c32 *text) {
// TODO
(void) dst;
(void) font;
- (void) color;
(void) position;
(void) scale;
(void) num_chars;
@@ -1199,6 +1148,12 @@ b8 hit_rectangle(Box area, vec2 point) {
return point.x >= area.x && point.x < area.x + area.width && point.y >= area.y && point.y < area.y + area.height;
}
+static b8 same_sign_(f64 a, f64 b) {
+ if (a >= EPSILON && b <= -EPSILON) return 0;
+ if (a <= -EPSILON && b >= EPSILON) return 0;
+ return 1;
+}
+
b8 hit_triangle(vec2 vertices[3], vec2 point) {
f64 x0 = vertices[0].x;
f64 y0 = vertices[0].y;