X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=util.cpp;fp=util.cpp;h=9b018825d333e269e3e0007b0300165af563b28f;hp=2f6e6947b28029b9830e1d9aee78e595580a249b;hb=0323e7512fd7e3402ca6c5da7b30ce7bb007a060;hpb=b63de2b092ee08427d4547164c3d4b1a5a1003e9 diff --git a/util.cpp b/util.cpp index 2f6e694..9b01882 100644 --- a/util.cpp +++ b/util.cpp @@ -157,7 +157,19 @@ GLuint compile_shader(const string &shader_src, GLenum type) GLint status; glGetShaderiv(obj, GL_COMPILE_STATUS, &status); if (status == GL_FALSE) { - fprintf(stderr, "Failed to compile shader: %s\n", shader_src.c_str()); + // Add some line numbers to easier identify compile errors. + string src_with_lines = "/* 1 */ "; + size_t lineno = 1; + for (char ch : shader_src) { + src_with_lines.push_back(ch); + if (ch == '\n') { + char buf[32]; + snprintf(buf, sizeof(buf), "/* %3zu */ ", ++lineno); + src_with_lines += buf; + } + } + + fprintf(stderr, "Failed to compile shader:\n%s\n", src_with_lines.c_str()); exit(1); }