diff --git a/include/list/typed_list.h b/include/list/typed_list.h index c5fddf6..24ea203 100644 --- a/include/list/typed_list.h +++ b/include/list/typed_list.h @@ -8,8 +8,8 @@ #define BASE_LIST_CAPACITY 1024 -#define CONCAT(A, B, C) A##B##C -#define LIST_TYPE_NAME(T) CONCAT(list_, T, _t) +#define CONCAT(A, B) A##B +#define LIST_TYPE_NAME(T) CONCAT(list_, T) #define MAKE_LIST_TYPE(T) \ typedef struct { \ @@ -68,7 +68,7 @@ MAKE_LIST_TYPE(void); -list_void_t *_create_list(Arena *arena, u64 size, u64 count); +list_void *_create_list(Arena *arena, u64 size, u64 count); void *_alloc_for_list(Arena *arena, u64 size); #endif // !TYPED_LIST_H diff --git a/src/list/typed_list.c b/src/list/typed_list.c index 80953a3..295864a 100644 --- a/src/list/typed_list.c +++ b/src/list/typed_list.c @@ -5,16 +5,15 @@ #include #include -list_void_t *_create_list(Arena *arena, u64 size, u64 count) { - list_void_t *list = - (list_void_t *)_alloc_for_list(arena, sizeof(list_void_t)); +list_void *_create_list(Arena *arena, u64 size, u64 count) { + list_void *list = (list_void *)_alloc_for_list(arena, sizeof(list_void)); if (!list) { return NULL; } list->items = (void *)_alloc_for_list(arena, size * count); if (!list->items) { - munmap(list, sizeof(list_void_t)); + munmap(list, sizeof(list_void)); return NULL; } memset(list->items, 0, sizeof(size * count)); diff --git a/src/rasteriser/rasteriser.c b/src/rasteriser/rasteriser.c index e1c07b4..6080142 100644 --- a/src/rasteriser/rasteriser.c +++ b/src/rasteriser/rasteriser.c @@ -11,8 +11,7 @@ #include #include -internal list_float_t *interpolate(Arena *arena, i32 i0, f32 d0, i32 i1, - f32 d1); +internal list_float *interpolate(Arena *arena, i32 i0, f32 d0, i32 i1, f32 d1); internal inline void order_triangle_points(triangle_t *triangle); @@ -34,16 +33,16 @@ void draw_filled_triangle(window_t *wnd, Arena *arena, triangle_t triangle) { i32 x2 = triangle.p2.x; i32 y2 = triangle.p2.y; - list_float_t *x01 = interpolate(arena, y0, x0, y1, x1); - list_float_t *x12 = interpolate(arena, y1, x1, y2, x2); - list_float_t *x02 = interpolate(arena, y0, x0, y2, x2); - list_float_t *x012 = NULL; + list_float *x01 = interpolate(arena, y0, x0, y1, x1); + list_float *x12 = interpolate(arena, y1, x1, y2, x2); + list_float *x02 = interpolate(arena, y0, x0, y2, x2); + list_float *x012 = NULL; list_pop(x01); // Last element of x01 is a duplicate of first element in x12 list_merge(f32, arena, x012, x01, x12); - list_float_t *x_left; - list_float_t *x_right; + list_float *x_left; + list_float *x_right; u64 middle = (u64)(floorf((f32)(x02->count) / 2.0f)); if (list_get(x02, middle) < list_get(x012, middle)) { x_left = x02; @@ -72,10 +71,10 @@ void draw_shaded_triangle(window_t *wnd, Arena *arena, triangle_t triangle) { i32 x2 = triangle.p2.x; i32 y2 = triangle.p2.y; - list_float_t *x01 = interpolate(arena, y0, x0, y1, x1); - list_float_t *x12 = interpolate(arena, y1, x1, y2, x2); - list_float_t *x02 = interpolate(arena, y0, x0, y2, x2); - list_float_t *x012 = NULL; + list_float *x01 = interpolate(arena, y0, x0, y1, x1); + list_float *x12 = interpolate(arena, y1, x1, y2, x2); + list_float *x02 = interpolate(arena, y0, x0, y2, x2); + list_float *x012 = NULL; list_pop(x01); // Last element of x01 is a duplicate of first element in x12 list_merge(f32, arena, x012, x01, x12); @@ -83,18 +82,18 @@ void draw_shaded_triangle(window_t *wnd, Arena *arena, triangle_t triangle) { f32 h0 = triangle.h0; f32 h1 = triangle.h1; f32 h2 = triangle.h2; - list_float_t *h01 = interpolate(arena, y0, h0, y1, h1); - list_float_t *h12 = interpolate(arena, y1, h1, y2, h2); - list_float_t *h02 = interpolate(arena, y0, h0, y2, h2); - list_float_t *h012 = NULL; + list_float *h01 = interpolate(arena, y0, h0, y1, h1); + list_float *h12 = interpolate(arena, y1, h1, y2, h2); + list_float *h02 = interpolate(arena, y0, h0, y2, h2); + list_float *h012 = NULL; list_pop(h01); // Last element of h01 is a duplicate of first element in h12 list_merge(f32, arena, h012, h01, h12); - list_float_t *x_left; - list_float_t *x_right; - list_float_t *h_left; - list_float_t *h_right; + list_float *x_left; + list_float *x_right; + list_float *h_left; + list_float *h_right; u64 middle = (u64)(floorf((f32)(x02->count) / 2.0f)); if (list_get(x02, middle) < list_get(x012, middle)) { x_left = x02; @@ -108,7 +107,7 @@ void draw_shaded_triangle(window_t *wnd, Arena *arena, triangle_t triangle) { h_right = h02; } - list_float_t *h_segment = NULL; + list_float *h_segment = NULL; i32 index = -1; i64 xl = -1; i64 xr = -1; @@ -128,7 +127,7 @@ void draw_shaded_triangle(window_t *wnd, Arena *arena, triangle_t triangle) { } void draw_line(window_t *wnd, Arena *arena, line_t line, colour_t colour) { - list_float_t *values = NULL; + list_float *values = NULL; if (abs(line.p1.x - line.p0.x) > abs(line.p1.y - line.p0.y)) { if (line.p1.x < line.p0.x) { @@ -169,9 +168,8 @@ void draw_line(window_t *wnd, Arena *arena, line_t line, colour_t colour) { } } -internal list_float_t *interpolate(Arena *arena, i32 i0, f32 d0, i32 i1, - f32 d1) { - list_float_t *values; +internal list_float *interpolate(Arena *arena, i32 i0, f32 d0, i32 i1, f32 d1) { + list_float *values; if (i0 == i1) { values = list_create_with_capacity(f32, arena, 20); if (values) {