Skip to content

Commit

Permalink
opengl: report linking errors from program compilation as well
Browse files Browse the repository at this point in the history
  • Loading branch information
ammen99 committed Feb 24, 2024
1 parent 997afd4 commit 857e210
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/core/opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,25 @@ GLuint compile_program(std::string vertex_source, std::string frag_source)
GL_CALL(glAttachShader(result_program, fragment_shader));
GL_CALL(glLinkProgram(result_program));

int s = GL_FALSE;
#define LENGTH 1024 * 128
char log[LENGTH];
GL_CALL(glGetProgramiv(result_program, GL_LINK_STATUS, &s));
GL_CALL(glGetProgramInfoLog(result_program, LENGTH, NULL, log));

if (s == GL_FALSE)
{
LOGE("Failed to link vertex shader:\n", vertex_source,
"\nFragment shader:\n", frag_source,
"\nLinker output:\n", log);

GL_CALL(glDeleteProgram(result_program));
}

/* won't be really deleted until program is deleted as well */
GL_CALL(glDeleteShader(vertex_shader));
GL_CALL(glDeleteShader(fragment_shader));

return result_program;
return (s == GL_FALSE) ? 0 : result_program;
}

void init()
Expand Down

0 comments on commit 857e210

Please sign in to comment.