91 const bool round = rectangle->radius > 0; |
91 const bool round = rectangle->radius > 0; |
92 const bool border = rectangle->thickness > 0; |
92 const bool border = rectangle->thickness > 0; |
93 |
93 |
94 // Compute shader flags |
94 // Compute shader flags |
95 int shader_flags = 0; |
95 int shader_flags = 0; |
|
96 // TODO: think about a bool-array to int utility function |
96 if (filled) shader_flags |= ASC_RECTANGLE_SHADER_FLAG_FILL; |
97 if (filled) shader_flags |= ASC_RECTANGLE_SHADER_FLAG_FILL; |
97 if (border) shader_flags |= ASC_RECTANGLE_SHADER_FLAG_BORDER; |
98 if (border) shader_flags |= ASC_RECTANGLE_SHADER_FLAG_BORDER; |
98 if (round) shader_flags |= ASC_RECTANGLE_SHADER_FLAG_ROUND; |
99 if (round) shader_flags |= ASC_RECTANGLE_SHADER_FLAG_ROUND; |
99 |
100 |
100 // Lookup table for the shader ID |
101 // Look up and activate the shader |
101 const int shader_ids[] = { |
|
102 -1, // unused |
|
103 ASC_SHADER_RECTANGLE_FILL, |
|
104 ASC_SHADER_RECTANGLE_DRAW_ROUND, |
|
105 ASC_SHADER_RECTANGLE_FILL_ROUND, |
|
106 ASC_SHADER_RECTANGLE_DRAW, |
|
107 ASC_SHADER_RECTANGLE_FILL_BORDER, |
|
108 ASC_SHADER_RECTANGLE_DRAW_ROUND, |
|
109 ASC_SHADER_RECTANGLE_FILL_BORDER_ROUND, |
|
110 }; |
|
111 |
|
112 // Look up and activate shader |
|
113 const AscShaderProgram *shader = asc_shader_lookup_or_create( |
102 const AscShaderProgram *shader = asc_shader_lookup_or_create( |
114 shader_ids[shader_flags], asc_rectangle_shader_create, shader_flags); |
103 ASC_SHADER_RECTANGLE(shader_flags), |
|
104 asc_rectangle_shader_create, shader_flags |
|
105 ); |
115 if (asc_shader_use(shader, camera)) return; |
106 if (asc_shader_use(shader, camera)) return; |
116 asc_cptr_cast(AscRectangleShader, rect_shader, shader); |
107 asc_cptr_cast(AscRectangleShader, rect_shader, shader); |
117 |
108 |
118 // Upload uniforms |
109 // Upload uniforms |
119 asc_shader_upload_model_matrix(shader, node); |
110 asc_shader_upload_model_matrix(shader, node); |
238 // Compute shader flags |
229 // Compute shader flags |
239 int shader_flags = 0; |
230 int shader_flags = 0; |
240 if (filled) shader_flags |= ASC_ELLIPSIS_SHADER_FLAG_FILL; |
231 if (filled) shader_flags |= ASC_ELLIPSIS_SHADER_FLAG_FILL; |
241 if (border) shader_flags |= ASC_ELLIPSIS_SHADER_FLAG_BORDER; |
232 if (border) shader_flags |= ASC_ELLIPSIS_SHADER_FLAG_BORDER; |
242 |
233 |
243 // Lookup table for the shader ID |
234 // Look up and activate the shader |
244 const int shader_ids[] = { |
|
245 -1, // unused |
|
246 ASC_SHADER_ELLIPSIS_FILL, |
|
247 ASC_SHADER_ELLIPSIS_DRAW, |
|
248 ASC_SHADER_ELLIPSIS_FILL_BORDER, |
|
249 }; |
|
250 |
|
251 // Look up and activate shader |
|
252 const AscShaderProgram *shader = asc_shader_lookup_or_create( |
235 const AscShaderProgram *shader = asc_shader_lookup_or_create( |
253 shader_ids[shader_flags], asc_ellipsis_shader_create, shader_flags); |
236 ASC_SHADER_ELLIPSIS(shader_flags), |
|
237 asc_ellipsis_shader_create, shader_flags |
|
238 ); |
254 if (asc_shader_use(shader, camera)) return; |
239 if (asc_shader_use(shader, camera)) return; |
255 asc_cptr_cast(AscEllipsisShader, ellipsis_shader, shader); |
240 asc_cptr_cast(AscEllipsisShader, ellipsis_shader, shader); |
256 |
241 |
257 // Upload uniforms |
242 // Upload uniforms |
258 asc_shader_upload_model_matrix(shader, node); |
243 asc_shader_upload_model_matrix(shader, node); |