mirror of https://github.com/axmolengine/axmol.git
Merge pull request #14965 from elloop/fix_opengl_log_function
fix opengl log function.
This commit is contained in:
commit
93d331f1e8
|
@ -587,17 +587,15 @@ void GLProgram::use()
|
||||||
|
|
||||||
static std::string logForOpenGLShader(GLuint shader)
|
static std::string logForOpenGLShader(GLuint shader)
|
||||||
{
|
{
|
||||||
std::string ret;
|
GLint logLength = 0;
|
||||||
GLint logLength = 0, charsWritten = 0;
|
|
||||||
|
|
||||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength);
|
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength);
|
||||||
if (logLength < 1)
|
if (logLength < 1)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
char *logBytes = (char*)malloc(logLength + 1);
|
char *logBytes = (char*)malloc(sizeof(char) * logLength);
|
||||||
glGetShaderInfoLog(shader, logLength, &charsWritten, logBytes);
|
glGetShaderInfoLog(shader, logLength, nullptr, logBytes);
|
||||||
logBytes[logLength] = '\0';
|
std::string ret(logBytes);
|
||||||
ret = logBytes;
|
|
||||||
|
|
||||||
free(logBytes);
|
free(logBytes);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -605,17 +603,15 @@ static std::string logForOpenGLShader(GLuint shader)
|
||||||
|
|
||||||
static std::string logForOpenGLProgram(GLuint program)
|
static std::string logForOpenGLProgram(GLuint program)
|
||||||
{
|
{
|
||||||
std::string ret;
|
GLint logLength = 0;
|
||||||
GLint logLength = 0, charsWritten = 0;
|
|
||||||
|
|
||||||
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength);
|
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength);
|
||||||
if (logLength < 1)
|
if (logLength < 1)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
char *logBytes = (char*)malloc(logLength + 1);
|
char *logBytes = (char*)malloc(sizeof(char) * logLength);
|
||||||
glGetProgramInfoLog(program, logLength, &charsWritten, logBytes);
|
glGetProgramInfoLog(program, logLength, nullptr, logBytes);
|
||||||
logBytes[logLength] = '\0';
|
std::string ret(logBytes);
|
||||||
ret = logBytes;
|
|
||||||
|
|
||||||
free(logBytes);
|
free(logBytes);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue