30 GLuint shader = glCreateShader(type);
31 glShaderSource(shader, 1, &source, NULL);
32 glCompileShader(shader);
35 glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
36 if (status == GL_FALSE)
41 glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len);
42 vector<char>
buf(len);
43 glGetShaderInfoLog(shader, len, &out_len, &buf[0]);
44 LOGI(
"Shader log:\n%s", &buf[0]);
46 glDeleteShader(shader);
56 glGetProgramiv(prog, GL_LINK_STATUS, &status);
57 if (status == GL_FALSE)
62 glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &len);
63 vector<char>
buf(len);
64 glGetProgramInfoLog(prog, len, &out_len, &buf[0]);
65 LOGI(
"Program log:\n%s", &buf[0]);
67 glDeleteProgram(prog);
76 GLuint prog = glCreateProgram();
80 glDeleteProgram(prog);
88 glDeleteProgram(prog);
92 glAttachShader(prog, vs);
93 glAttachShader(prog, fs);
101 LOGE(
"Failed to link program.");
110 GLuint prog = glCreateProgram();
114 glDeleteProgram(prog);
118 glAttachShader(prog, cs);
125 LOGE(
"Failed to link program.");
137 LOGE(
"Failed to open file: %s.", path);
141 fseek(file, 0, SEEK_END);
142 long len = ftell(file);
145 char *
buf = (
char*)malloc(len + 1);
152 long ret = fread(buf, 1, len, file);
171 LOGI(
"Compiling vertex/fragment shader: %s, %s.", vs_source, fs_source);
193 LOGI(
"Compiling compute shader from %s.", cs_source);
226 FILE *ret = fopen(join_path.c_str(),
mode);
227 LOGI(
"Opening: %s (%s).", join_path.c_str(), ret ?
"success" :
"failure");
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)
static bool check_program(GLuint prog)
GLuint common_compile_shader(const char *vs_source, const char *fs_source)
void common_set_basedir(const char *basedir)
GLsizei GLsizei GLchar * source
static bool read_file_string(const char *path, char **out_buf)
static GLuint common_compile(GLenum type, const char *source)
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)
static string common_basedir
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count