From 3c1b90a736e3958a9f0545f04b1af7fc00b74b4e Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Wed, 2 May 2018 19:35:20 +0100 Subject: Improve glprog_load to take sentinel terminated lists Numerous times a new uniform has been added and the corresponding increment of the nunis parameter was forgotten causing confusion. This should not happen anymore. --- glprog.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'glprog.c') diff --git a/glprog.c b/glprog.c index 19e0d44..5019af2 100644 --- a/glprog.c +++ b/glprog.c @@ -40,19 +40,17 @@ void detach_shaders(GLuint prog) gl_prog_detachshdr(prog, shdr); } -GLuint glprog_load(int nshdrs, const struct shdrdat *shdrs, int nunis, const struct unidat *unis) +GLuint glprog_load(const struct shdrdat *shdrs, const struct unidat *unis) { GLuint prog; GLint success; char log[LOGSIZE]; - assert(nshdrs > 0); assert(shdrs != NULL); - assert(nunis <= 0 || unis != NULL); prog = gl_prog_create(); - for (int i = 0; i < nshdrs; i++) { - GLuint shdr = load_shader(&shdrs[i]); + for (const struct shdrdat *s = shdrs; s->type != 0; s++) { + GLuint shdr = load_shader(s); gl_prog_attachshdr(prog, shdr); gl_shdr_del(shdr); } @@ -65,8 +63,10 @@ GLuint glprog_load(int nshdrs, const struct shdrdat *shdrs, int nunis, const str detach_shaders(prog); - for (int i = 0; i < nunis; i++) - *unis[i].loc = gl_uni_loc(prog, unis[i].name); + if (unis == NULL) return prog; + + for (const struct unidat *u = unis; u->name != NULL; u++) + *u->loc = gl_uni_loc(prog, u->name); return prog; } -- cgit v1.2.3-54-g00ecf