|
|
|
|
@ -4,10 +4,6 @@
|
|
|
|
|
#include "util.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: remove and fix hack for dynamic stack allocation
|
|
|
|
|
#define INFO_LOG_MAX_LENGTH 312 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
shader_program* |
|
|
|
|
shaderInit(const char* vertex_code, const char* frag_code) |
|
|
|
|
{ |
|
|
|
|
@ -42,20 +38,24 @@ shaderInit(const char* vertex_code, const char* frag_code)
|
|
|
|
|
GLint isLinked = 0; |
|
|
|
|
glGetProgramiv(sp->program_id, GL_LINK_STATUS, &isLinked); |
|
|
|
|
if (isLinked == GL_FALSE) { |
|
|
|
|
GLint maxLength = INFO_LOG_MAX_LENGTH; |
|
|
|
|
glGetProgramiv(sp->program_id, GL_INFO_LOG_LENGTH, &maxLength); |
|
|
|
|
#ifdef _WIN32 |
|
|
|
|
GLchar infoLog[312] = { 0 }; |
|
|
|
|
#else |
|
|
|
|
GLchar infoLog[maxLength] = { 0 }; |
|
|
|
|
#endif |
|
|
|
|
glGetProgramInfoLog(sp->program_id, maxLength, &maxLength, &infoLog[0]); |
|
|
|
|
GLint info_len = 0; |
|
|
|
|
glGetProgramiv(sp->program_id, GL_INFO_LOG_LENGTH, &info_len); |
|
|
|
|
|
|
|
|
|
char* infoLog = UTIL_ALLOC(info_len, char); |
|
|
|
|
glGetProgramInfoLog(sp->program_id, info_len, &info_len, &infoLog[0]); |
|
|
|
|
LOG(Error) << infoLog << "\n"; |
|
|
|
|
glDeleteProgram(sp->program_id); |
|
|
|
|
utilSafeFree(infoLog); |
|
|
|
|
|
|
|
|
|
glDeleteProgram(sp->program_id); |
|
|
|
|
return nullptr; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return sp; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
shaderFree(shader_program* shader) |
|
|
|
|
{ |
|
|
|
|
glDeleteProgram(shader->program_id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|