src/2d.c

changeset 226
18327d2df79d
parent 223
4f32c7755138
--- a/src/2d.c	Fri Jul 25 18:58:50 2025 +0200
+++ b/src/2d.c	Fri Jul 25 19:19:54 2025 +0200
@@ -93,25 +93,16 @@
 
     // Compute shader flags
     int shader_flags = 0;
+    // TODO: think about a bool-array to int utility function
     if (filled) shader_flags |= ASC_RECTANGLE_SHADER_FLAG_FILL;
     if (border) shader_flags |= ASC_RECTANGLE_SHADER_FLAG_BORDER;
     if (round) shader_flags |= ASC_RECTANGLE_SHADER_FLAG_ROUND;
 
-    // Lookup table for the shader ID
-    const int shader_ids[] = {
-        -1, // unused
-        ASC_SHADER_RECTANGLE_FILL,
-        ASC_SHADER_RECTANGLE_DRAW_ROUND,
-        ASC_SHADER_RECTANGLE_FILL_ROUND,
-        ASC_SHADER_RECTANGLE_DRAW,
-        ASC_SHADER_RECTANGLE_FILL_BORDER,
-        ASC_SHADER_RECTANGLE_DRAW_ROUND,
-        ASC_SHADER_RECTANGLE_FILL_BORDER_ROUND,
-    };
-
-    // Look up and activate shader
+    // Look up and activate the shader
     const AscShaderProgram *shader = asc_shader_lookup_or_create(
-        shader_ids[shader_flags], asc_rectangle_shader_create, shader_flags);
+        ASC_SHADER_RECTANGLE(shader_flags),
+        asc_rectangle_shader_create, shader_flags
+    );
     if (asc_shader_use(shader, camera)) return;
     asc_cptr_cast(AscRectangleShader, rect_shader, shader);
 
@@ -240,17 +231,11 @@
     if (filled) shader_flags |= ASC_ELLIPSIS_SHADER_FLAG_FILL;
     if (border) shader_flags |= ASC_ELLIPSIS_SHADER_FLAG_BORDER;
 
-    // Lookup table for the shader ID
-    const int shader_ids[] = {
-        -1, // unused
-        ASC_SHADER_ELLIPSIS_FILL,
-        ASC_SHADER_ELLIPSIS_DRAW,
-        ASC_SHADER_ELLIPSIS_FILL_BORDER,
-    };
-
-    // Look up and activate shader
+    // Look up and activate the shader
     const AscShaderProgram *shader = asc_shader_lookup_or_create(
-        shader_ids[shader_flags], asc_ellipsis_shader_create, shader_flags);
+        ASC_SHADER_ELLIPSIS(shader_flags),
+        asc_ellipsis_shader_create, shader_flags
+    );
     if (asc_shader_use(shader, camera)) return;
     asc_cptr_cast(AscEllipsisShader, ellipsis_shader, shader);
 

mercurial