]> git.tdb.fi Git - libs/gl.git/commitdiff
Read shader and program info logs directly into an std::string
authorMikko Rasa <tdb@tdb.fi>
Mon, 25 Jan 2021 01:07:18 +0000 (03:07 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 25 Jan 2021 01:07:18 +0000 (03:07 +0200)
source/program.cpp
source/shader.cpp

index a5128e9b77436ef13f24bbf1de7b2e7f3b263526..6313043ea84361c3f7fbc543324c997eb56d5fc6 100644 (file)
@@ -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;
 }
 
index d1938ba702fd0c629133e7e588ffebc816fa6d92..02dcc0dcff789fe142f9b47d4bde5ad2e48fe7fa 100644 (file)
@@ -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;
 }