Make sure no duplicated shader is added somewhere else

This commit is contained in:
Benau 2016-12-18 13:49:58 +08:00
parent 2a9656bfdc
commit 7ea4f30824
2 changed files with 10 additions and 3 deletions

View File

@ -356,12 +356,12 @@ public:
glGetProgramiv(m_program, GL_LINK_STATUS, &Result);
if (Result == GL_FALSE) {
int info_length;
Log::error("GLWrapp", "Error when linking these shaders :");
Log::error("Shader", "Error when linking these shaders :");
printFileList(args...);
glGetProgramiv(m_program, GL_INFO_LOG_LENGTH, &info_length);
char *error_message = new char[info_length];
glGetProgramInfoLog(m_program, info_length, NULL, error_message);
Log::error("GLWrapp", error_message);
Log::error("Shader", error_message);
delete[] error_message;
}
} // loadProgram

View File

@ -59,6 +59,13 @@ const std::string& ShaderFilesManager::getHeader()
GLuint ShaderFilesManager::addShaderFile(const std::string &file,
unsigned type)
{
#ifdef DEBUG
// Make sure no duplicated shader is added somewhere else
std::unordered_map<std::string, GLuint>::const_iterator i =
m_shader_files_loaded.find(file);
assert(i == m_shader_files_loaded.end());
#endif
GLuint id = glCreateShader(type);
std::ostringstream code;