From: Mikko Rasa Date: Mon, 25 Jan 2021 01:07:18 +0000 (+0200) Subject: Read shader and program info logs directly into an std::string X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=61c8b6e824977ce025c979005b141ff4bb02b0e9;p=libs%2Fgl.git Read shader and program info logs directly into an std::string --- diff --git a/source/program.cpp b/source/program.cpp index a5128e9b..6313043e 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -333,10 +333,9 @@ bool Program::uniform_location_compare(const UniformInfo *uni1, const UniformInf string Program::get_info_log() const { GLsizei len = get_program_i(id, GL_INFO_LOG_LENGTH); - char *buf = new char[len+1]; - glGetProgramInfoLog(id, len+1, &len, buf); - string log(buf, len); - delete[] buf; + string log(len+1, 0); + glGetProgramInfoLog(id, len+1, &len, &log[0]); + log.erase(len); return log; } diff --git a/source/shader.cpp b/source/shader.cpp index d1938ba7..02dcc0dc 100644 --- a/source/shader.cpp +++ b/source/shader.cpp @@ -77,10 +77,9 @@ void Shader::compile() string Shader::get_info_log() const { GLsizei len = get_shader_i(id, GL_INFO_LOG_LENGTH); - char *buf = new char[len+1]; - glGetShaderInfoLog(id, len+1, &len, buf); - string log(buf, len); - delete[] buf; + string log(len+1, 0); + glGetShaderInfoLog(id, len+1, &len, &log[0]); + log.erase(len); return log; }