mirror of
https://github.com/thepigeongenerator/mcaselector-lite.git
synced 2025-12-17 11:05:45 +01:00
add shader compilation error logging
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "../util/vec/float2.h"
|
||||
#include "shader.h"
|
||||
#include "../error.h"
|
||||
|
||||
#define VERTC 6
|
||||
GLuint pipe;
|
||||
@@ -36,6 +37,15 @@ int render_init(void) {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STATIC_DRAW);
|
||||
|
||||
int len;
|
||||
glGetProgramiv(pipe, GL_INFO_LOG_LENGTH, &len);
|
||||
if (len > 0) {
|
||||
char log[len];
|
||||
glGetProgramInfoLog(pipe, len, &len, log);
|
||||
log[len - 1] = '\0'; // terminate the string one character sooner since the log includes a newline
|
||||
fatal("error whilst linking the pipe: '%s'", log);
|
||||
}
|
||||
|
||||
// init the VAO
|
||||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../error.h"
|
||||
|
||||
#define NAM_S(name) _binary_res_##name##_start // name of a start variable
|
||||
#define NAM_E(name) _binary_res_##name##_end // name of an end variable
|
||||
|
||||
@@ -22,6 +24,16 @@ static GLuint shader_compile(GLenum type, char const* src, size_t len) {
|
||||
GLuint shader = glCreateShader(type);
|
||||
glShaderSource(shader, 1, &src, &ilen);
|
||||
glCompileShader(shader);
|
||||
|
||||
// repurposing ilen for the max length of the shader log
|
||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &ilen);
|
||||
if (ilen > 0) {
|
||||
char log[ilen];
|
||||
glGetShaderInfoLog(shader, ilen, &ilen, log);
|
||||
log[ilen - 1] = '\0'; // terminate the string one character sooner since the log includes a newline
|
||||
error("error whilst compiling shader type '0x%x': '%s'", type, log);
|
||||
}
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user