aboutsummaryrefslogtreecommitdiffstats
path: root/glprog.c
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2018-10-27 12:41:58 +0100
committerTomasz Kramkowski <tk@the-tk.com>2018-10-27 12:47:05 +0100
commitd3f47e042aebd5fbf86477abf7058704657e8430 (patch)
tree4996f0c46f7ebf5037ee7fecceb161bbeb4e549e /glprog.c
parentadbc72e159d48e6b1ad091e6ac19fd1cd6d5f798 (diff)
downloadfaqe-d3f47e042aebd5fbf86477abf7058704657e8430.tar.gz
faqe-d3f47e042aebd5fbf86477abf7058704657e8430.tar.xz
faqe-d3f47e042aebd5fbf86477abf7058704657e8430.zip
Cleanup pass
Diffstat (limited to 'glprog.c')
-rw-r--r--glprog.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/glprog.c b/glprog.c
index 93dc22c..edb819e 100644
--- a/glprog.c
+++ b/glprog.c
@@ -39,6 +39,7 @@ static const struct {
},
};
+// readfile: read a whole file into a buffer
static bool readfile(char **data, size_t *size, const char *name)
{
FILE *f;
@@ -63,17 +64,19 @@ static bool readfile(char **data, size_t *size, const char *name)
*data = erealloc(*data, *size);
}
+ fclose(f);
+
*size = len;
*data = erealloc(*data, *size);
return true;
}
+// compile: compile shader component
static GLuint compile(const char *src, size_t len, const char *pre, GLuint type)
{
GLuint id;
GLint success;
- char log[LOGSIZE];
static const char *common_pre =
#define SH_VER(v) "#version " v "\n"
#define SH_UNI(type, name) "uniform " #type " " #name ";\n"
@@ -88,6 +91,7 @@ static GLuint compile(const char *src, size_t len, const char *pre, GLuint type)
gl_shdr_param(id, GL_COMPILE_STATUS, &success);
if (!success) {
+ char log[LOGSIZE];
gl_shdr_infolog(id, sizeof log, NULL, log);
eprintf("Failed to compile shader:\n%s", log);
}
@@ -108,7 +112,7 @@ static void load_shader(struct shader *s, const char *path)
{
GLuint prog;
GLint success, pos = 0;
- char log[LOGSIZE], *full, *src = NULL;
+ char *full, *src = NULL;
size_t srclen = 0, fullsz;
GLint texture = 0;
@@ -139,6 +143,7 @@ static void load_shader(struct shader *s, const char *path)
gl_prog_link(prog);
gl_prog_param(prog, GL_LINK_STATUS, &success);
if (!success) {
+ char log[LOGSIZE];
gl_prog_infolog(prog, sizeof log, NULL, log);
eprintf("Failed to link program\n%s", log);
}
@@ -153,6 +158,7 @@ static void load_shader(struct shader *s, const char *path)
s->prog = prog;
}
+// glprog_init: compile and link all shader programs
void glprog_init(void)
{
GLint pos = 0;