62 .defines.frag_list_select = flags |
62 .defines.frag_list_select = flags |
63 }, &codes)) { |
63 }, &codes)) { |
64 asc_error("Loading rectangle shader failed."); |
64 asc_error("Loading rectangle shader failed."); |
65 return NULL; |
65 return NULL; |
66 } |
66 } |
|
67 // TODO: find better way to deal with inheritance (&shader->program just looks bad) |
67 AscRectangleShader *shader = asc_shader_create(codes, sizeof(*shader)); |
68 AscRectangleShader *shader = asc_shader_create(codes, sizeof(*shader)); |
68 if (shader == NULL) { |
69 if (asc_shader_invalid(&shader->program)) { |
69 asc_shader_free_codes(codes); |
70 asc_shader_free_codes(codes); |
70 return NULL; |
71 return (AscShaderProgram*) shader; |
71 } |
72 } |
72 shader->size = glGetUniformLocation(shader->program.gl_id, "size"); |
73 shader->size = glGetUniformLocation(shader->program.gl_id, "size"); |
73 if (asc_test_flag(flags, ASC_RECTANGLE_SHADER_FLAG_FILL)) { |
74 if (asc_test_flag(flags, ASC_RECTANGLE_SHADER_FLAG_FILL)) { |
74 shader->color = glGetUniformLocation(shader->program.gl_id, "color"); |
75 shader->color = glGetUniformLocation(shader->program.gl_id, "color"); |
75 } else { |
76 } else { |
130 }; |
131 }; |
131 |
132 |
132 // Look up and activate shader |
133 // Look up and activate shader |
133 const AscRectangleShader *shader = asc_shader_lookup_or_create( |
134 const AscRectangleShader *shader = asc_shader_lookup_or_create( |
134 shader_ids[shader_flags], asc_rectangle_shader_create, shader_flags); |
135 shader_ids[shader_flags], asc_rectangle_shader_create, shader_flags); |
135 if (shader == NULL) return; |
136 // TODO: how to remove the following cast? |
|
137 if (asc_shader_invalid((AscShaderProgram*)shader)) return; |
136 asc_shader_use(&shader->program, camera); |
138 asc_shader_use(&shader->program, camera); |
137 |
139 |
138 // Upload uniforms |
140 // Upload uniforms |
139 // TODO: uploading model matrix could be a helper function |
141 // TODO: uploading model matrix could be a helper function |
140 glUniformMatrix4fv(shader->program.model, 1, |
142 glUniformMatrix4fv(shader->program.model, 1, |