31 GL_CHECK(glShaderSource(shader, 1, &source, NULL));
35 GL_CHECK(glGetShaderiv(shader, GL_COMPILE_STATUS, &status));
36 if (status == GL_FALSE)
41 GL_CHECK(glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len));
42 vector<char>
buf(len);
43 GL_CHECK(glGetShaderInfoLog(shader, len, &out_len, &buf[0]));
44 LOGI(
"Shader log:\n%s", &buf[0]);
56 GL_CHECK(glGetProgramiv(prog, GL_LINK_STATUS, &status));
57 if (status == GL_FALSE)
62 GL_CHECK(glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &len));
63 vector<char>
buf(len);
64 GL_CHECK(glGetProgramInfoLog(prog, len, &out_len, &buf[0]));
65 LOGI(
"Program log:\n%s", &buf[0]);
80 glDeleteProgram(prog);
101 LOGE(
"Failed to link program.");
109 const char *tc_source,
const char *te_source,
const char *geom_source,
110 const char *fs_source)
112 GLuint prog = glCreateProgram();
131 for (
unsigned i = 0; i < 5; i++)
143 for (
auto shader : shaders)
147 GL_CHECK(glAttachShader(prog, shader));
152 for (
auto shader : shaders)
162 LOGE(
"Failed to link program.");
169 for (
auto shader : shaders)
197 LOGE(
"Failed to link program.");
209 LOGE(
"Failed to open file: %s.", path);
213 fseek(file, 0, SEEK_END);
214 long len = ftell(file);
217 char *
buf = (
char*)malloc(len + 1);
224 long ret = fread(buf, 1, len, file);
243 LOGI(
"Compiling vertex/fragment shader: %s, %s.", vs_source, fs_source);
264 const char *tc_source,
const char *te_source,
const char *geom_source,
265 const char *fs_source)
267 LOGI(
"Compiling shader: %s, %s, %s, %s, %s.",
269 tc_source ? tc_source :
"none",
270 te_source ? te_source :
"none",
271 geom_source ? geom_source :
"none",
278 char *geom_buf = NULL;
319 LOGI(
"Compiling compute shader from %s.", cs_source);
352 FILE *ret = fopen(join_path.c_str(),
mode);
353 LOGI(
"Opening: %s (%s).", join_path.c_str(), ret ?
"success" :
"failure");
static GLuint common_compile(GLenum type, const char *source)
#define GL_TESS_CONTROL_SHADER_EXT
static bool check_program(GLuint prog)
GLuint common_compile_compute_shader_from_file(const char *cs_source)
GLuint common_compile_shader_from_file(const char *vs_source, const char *fs_source)
bool common_read_file_string(const char *path, char **out_buf)
static string common_basedir
GLuint common_compile_shader(const char *vs_source, const char *fs_source)
void common_set_basedir(const char *basedir)
GLsizei GLsizei GLchar * source
#define GL_TESS_EVALUATION_SHADER_EXT
string common_get_path(const char *basepath)
FILE * common_fopen(const char *path, const char *mode)
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint common_compile_compute_shader(const char *cs_source)
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
#define GL_GEOMETRY_SHADER_EXT