src/2d.c

changeset 228
ecda73508be6
parent 226
18327d2df79d
equal deleted inserted replaced
227:a5775e8dbc13 228:ecda73508be6
26 */ 26 */
27 27
28 #include "ascension/2d.h" 28 #include "ascension/2d.h"
29 29
30 #include "ascension/constants.h" 30 #include "ascension/constants.h"
31 #include "ascension/error.h"
32 #include "ascension/shader.h" 31 #include "ascension/shader.h"
33 32
34 #include <assert.h> 33 #include <assert.h>
35 34
36 typedef struct asc_rectangle_shader_s { 35 typedef struct asc_rectangle_shader_s {
90 const bool filled = rectangle->filled; 89 const bool filled = rectangle->filled;
91 const bool round = rectangle->radius > 0; 90 const bool round = rectangle->radius > 0;
92 const bool border = rectangle->thickness > 0; 91 const bool border = rectangle->thickness > 0;
93 92
94 // Compute shader flags 93 // Compute shader flags
95 int shader_flags = 0; 94 int flags = asc_create_flags(1, 3, filled, round, border);
96 // TODO: think about a bool-array to int utility function
97 if (filled) shader_flags |= ASC_RECTANGLE_SHADER_FLAG_FILL;
98 if (border) shader_flags |= ASC_RECTANGLE_SHADER_FLAG_BORDER;
99 if (round) shader_flags |= ASC_RECTANGLE_SHADER_FLAG_ROUND;
100 95
101 // Look up and activate the shader 96 // Look up and activate the shader
102 const AscShaderProgram *shader = asc_shader_lookup_or_create( 97 const AscShaderProgram *shader = asc_shader_lookup_or_create(
103 ASC_SHADER_RECTANGLE(shader_flags), 98 ASC_SHADER_RECTANGLE(flags),
104 asc_rectangle_shader_create, shader_flags 99 asc_rectangle_shader_create, flags
105 ); 100 );
106 if (asc_shader_use(shader, camera)) return; 101 if (asc_shader_use(shader, camera)) return;
107 asc_cptr_cast(AscRectangleShader, rect_shader, shader); 102 asc_cptr_cast(AscRectangleShader, rect_shader, shader);
108 103
109 // Upload uniforms 104 // Upload uniforms
225 220
226 const bool filled = ellipsis->filled; 221 const bool filled = ellipsis->filled;
227 const bool border = ellipsis->thickness > 0; 222 const bool border = ellipsis->thickness > 0;
228 223
229 // Compute shader flags 224 // Compute shader flags
230 int shader_flags = 0; 225 int shader_flags = asc_create_flags(1, 2, filled, border);
231 if (filled) shader_flags |= ASC_ELLIPSIS_SHADER_FLAG_FILL;
232 if (border) shader_flags |= ASC_ELLIPSIS_SHADER_FLAG_BORDER;
233 226
234 // Look up and activate the shader 227 // Look up and activate the shader
235 const AscShaderProgram *shader = asc_shader_lookup_or_create( 228 const AscShaderProgram *shader = asc_shader_lookup_or_create(
236 ASC_SHADER_ELLIPSIS(shader_flags), 229 ASC_SHADER_ELLIPSIS(shader_flags),
237 asc_ellipsis_shader_create, shader_flags 230 asc_ellipsis_shader_create, shader_flags

mercurial