aboutsummaryrefslogtreecommitdiffstats
path: root/glprog.c
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2018-10-22 01:41:32 +0300
committerTomasz Kramkowski <tk@the-tk.com>2018-10-22 01:41:32 +0300
commit0cd7f50e11d89311762ae062bb1cfa876a317353 (patch)
tree2d4fbf2ff330c5d150f660d1aefd145d3135ddd0 /glprog.c
parent3c7790062aa05653efa0f8ee230c07cb7ead91dd (diff)
downloadfaqe-0cd7f50e11d89311762ae062bb1cfa876a317353.tar.gz
faqe-0cd7f50e11d89311762ae062bb1cfa876a317353.tar.xz
faqe-0cd7f50e11d89311762ae062bb1cfa876a317353.zip
use shaders/data.h for the definition of vertices
Now that shaders/data.h is in place, it can be taken to the next extreme. The information stored in shaders/data.h is plentiful enough that vertex attribute location information can be standardised, the definition of vertices can be specified in only one place and the bindings for vertex information can be generated. It's around this point in time that I wish there was a better pre-processor for all this. It might make things a lot cleaner.
Diffstat (limited to 'glprog.c')
-rw-r--r--glprog.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/glprog.c b/glprog.c
index 2996889..10f01a4 100644
--- a/glprog.c
+++ b/glprog.c
@@ -107,7 +107,7 @@ static void detach_shaders(GLuint prog)
static void load_shader(struct shader *s, const char *path)
{
GLuint prog;
- GLint success;
+ GLint success, pos = 0;
char log[LOGSIZE], *full, *src = NULL;
size_t srclen = 0, fullsz;
@@ -133,6 +133,8 @@ static void load_shader(struct shader *s, const char *path)
}
free(src);
free(full);
+#define SH_IN(_, name) gl_attr_bindloc(prog, pos++, #name);
+#include "shaders/data.h"
gl_prog_link(prog);
gl_prog_param(prog, GL_LINK_STATUS, &success);
if (!success) {
@@ -150,6 +152,8 @@ static void load_shader(struct shader *s, const char *path)
void glprog_init(void)
{
+ GLint pos = 0;
#define SH_PROG(name) load_shader(&prog.name, "shaders/" #name);
+#define SH_IN(_, name) prog.attr.name = pos++;
#include "shaders/data.h"
}