31 const char *
strings[1] = { NULL };
34 *shader =
GL_CHECK(glCreateShader(shaderType));
36 GL_CHECK(glShaderSource(*shader, 1, strings, NULL));
39 free((
void *)(strings[0]));
45 GL_CHECK(glGetShaderiv(*shader, GL_COMPILE_STATUS, &status));
51 char *debugSource = NULL;
52 char *errorLog = NULL;
55 GL_CHECK(glGetShaderiv(*shader, GL_SHADER_SOURCE_LENGTH, &length));
56 debugSource = (
char *)malloc(length);
57 GL_CHECK(glGetShaderSource(*shader, length, NULL, debugSource));
58 LOGE(
"Debug source START:\n%s\nDebug source END\n\n", debugSource);
62 GL_CHECK(glGetShaderiv(*shader, GL_INFO_LOG_LENGTH, &length));
63 errorLog = (
char *)malloc(length);
64 GL_CHECK(glGetShaderInfoLog(*shader, length, NULL, errorLog));
65 LOGE(
"Log START:\n%s\nLog END\n\n", errorLog);
68 LOGE(
"Compilation FAILED!\n\n");
75 FILE *file = fopen(filename,
"rb");
78 LOGE(
"Cannot read file '%s'\n", filename);
82 fseek(file, 0, SEEK_END);
86 fseek(file, 0, SEEK_SET);
87 char *shader = (
char *)calloc(length + 1,
sizeof(
char));
90 LOGE(
"Out of memory at %s:%i\n", __FILE__, __LINE__);
94 size_t numberOfBytesRead = fread(shader,
sizeof(
char), length, file);
95 if (numberOfBytesRead != length)
97 LOGE(
"Error reading %s (read %d of %ld)", filename, numberOfBytesRead, length);
static char * loadShader(const char *filename)
Load shader source from a file into memory.
GLsizei const GLchar ** strings
GLenum GLuint GLenum GLsizei length
static void processShader(GLuint *shader, const char *filename, GLint shaderType)
Create shader, load in source, compile, and dump debug as necessary.
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count