1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-13 07:30:21 +00:00

Ensures log memory is automatically initialised.

This commit is contained in:
Thomas Harte 2019-02-18 22:08:03 -05:00
parent 40bfde41cb
commit ddf5e1632d

View File

@ -9,6 +9,7 @@
#include "Shader.hpp"
#include "../../Log.hpp"
#include <vector>
using namespace Outputs::Display::OpenGL;
@ -31,10 +32,10 @@ GLuint Shader::compile_shader(const std::string &source, GLenum type) {
GLint logLength;
test_gl(glGetShaderiv, shader, GL_INFO_LOG_LENGTH, &logLength);
if(logLength > 0) {
GLchar *log = new GLchar[std::size_t(logLength)];
test_gl(glGetShaderInfoLog, shader, logLength, &logLength, log);
LOG("Compile log:\n" << log);
delete[] log;
const auto length = std::vector<GLchar>::size_type(logLength);
std::vector<GLchar> log(length);
test_gl(glGetShaderInfoLog, shader, logLength, &logLength, log.data());
LOG("Compile log:\n" << log.data());
}
throw (type == GL_VERTEX_SHADER) ? VertexShaderCompilationError : FragmentShaderCompilationError;