src/shader.c

changeset 158
f650994ec543
parent 153
4116e2bd501b
equal deleted inserted replaced
157:d6c2f028d8c9 158:f650994ec543
205 void asc_shader_free_codes(AscShaderCodes codes) { 205 void asc_shader_free_codes(AscShaderCodes codes) {
206 cxFreeDefault(codes.vtx); 206 cxFreeDefault(codes.vtx);
207 cxFreeDefault(codes.frag); 207 cxFreeDefault(codes.frag);
208 } 208 }
209 209
210 const void *asc_shader_register(unsigned int id, asc_shader_create_func create_func) { 210 const void *asc_shader_register(unsigned int id, asc_shader_create_func create_func, int create_flags) {
211 AscGLContext *glctx = asc_active_glctx; 211 AscGLContext *glctx = asc_active_glctx;
212 #ifndef NDEBUG 212 #ifndef NDEBUG
213 { 213 {
214 const AscShaderProgram *prog = asc_shader_lookup(id); 214 const AscShaderProgram *prog = asc_shader_lookup(id);
215 if (prog != NULL) { 215 if (prog != NULL) {
217 // still return it, so that the caller does not die immediately 217 // still return it, so that the caller does not die immediately
218 return prog; 218 return prog;
219 } 219 }
220 } 220 }
221 #endif 221 #endif
222 AscShaderProgram *prog = create_func(); 222 AscShaderProgram *prog = create_func(create_flags);
223 prog->id = id; 223 prog->id = id;
224 cxListAdd(glctx->shaders, prog); 224 cxListAdd(glctx->shaders, prog);
225 return prog; 225 return prog;
226 } 226 }
227 227
231 if (prog->id == id) return prog; 231 if (prog->id == id) return prog;
232 } 232 }
233 return NULL; 233 return NULL;
234 } 234 }
235 235
236 const void *asc_shader_lookup_or_create(unsigned int id, asc_shader_create_func create_func) { 236 const void *asc_shader_lookup_or_create(unsigned int id, asc_shader_create_func create_func, int create_flags) {
237 const AscShaderProgram *prog = asc_shader_lookup(id); 237 const AscShaderProgram *prog = asc_shader_lookup(id);
238 if (prog == NULL) { 238 if (prog == NULL) {
239 return asc_shader_register(id, create_func); 239 return asc_shader_register(id, create_func, create_flags);
240 } 240 }
241 return prog; 241 return prog;
242 } 242 }
243 243
244 void asc_shader_clear_registry(void) { 244 void asc_shader_clear_registry(void) {

mercurial