summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2025-04-25 09:06:27 +0200
committerMitya Selivanov <automainint@guattari.tech>2025-04-25 09:06:27 +0200
commit3f37db0647cb31955c8ad271f747c8e1ee5d2124 (patch)
treeafcf171fc145f9cfe0f13c3e8f22348015c522da
parent27291f388b02c6ba88efb79b9728b65f158589ef (diff)
downloadreduced_system_layer-3f37db0647cb31955c8ad271f747c8e1ee5d2124.zip
Global gamma is disabled by default
-rw-r--r--graphics.c61
-rw-r--r--runtime.c48
2 files changed, 54 insertions, 55 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;
diff --git a/runtime.c b/runtime.c
index 3f20820..01877af 100644
--- a/runtime.c
+++ b/runtime.c
@@ -612,7 +612,7 @@ typedef struct {
i32 antialiasing_scale;
b8 exact_resolution : 1;
- b8 disable_gamma : 1;
+ b8 enable_gamma : 1;
b8 graceful_shutdown : 1;
b8 enable_clipboard_text : 1;
b8 enable_clipboard_image : 1;
@@ -781,6 +781,50 @@ static i64 max2_i64_(i64 x, i64 y) {
return x > y ? x : 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;
+}
+
// ================================================================
//
// Log
@@ -1830,7 +1874,7 @@ static void convert_pixels_for_window_(void) {
vec3_f32 *im = _internal_row;
vec3_f32 *im_end = _internal_row + dst_width;
- if (!g_platform.disable_gamma)
+ if (g_platform.enable_gamma)
for (; im < im_end; ++im) {
im->x = gamma_(im->x * k);
im->y = gamma_(im->y * k);