Skip to content

Instantly share code, notes, and snippets.

@yurivish
Last active August 29, 2015 14:02
Show Gist options
  • Save yurivish/7a54e847c2c542fb8da2 to your computer and use it in GitHub Desktop.
Save yurivish/7a54e847c2c542fb8da2 to your computer and use it in GitHub Desktop.
function getInfoLog(obj::GLuint)
# Return the info log for obj, whether it be a shader or a program.
isShader = glIsShader(obj)
getiv = isShader == GL_TRUE ? glGetShaderiv : glGetProgramiv
getInfo = isShader == GL_TRUE ? glGetShaderInfoLog : glGetProgramInfoLog
# Get the maximum possible length for the descriptive error message
int::Array{GLint, 1} = [0]
getiv(obj, GL_INFO_LOG_LENGTH, int)
maxlength = int[1]
# Return the text of the message if there is any
if maxlength > 0
buffer = zeros(GLchar, maxlength)
sizei::Array{GLsizei, 1} = [0]
getInfo(obj, maxlength, sizei, buffer)
length = sizei[1]
bytestring(pointer(buffer), length)
else
""
end
end
function validateShader(shader)
success::Array{GLint, 1} = [0]
glGetShaderiv(shader, GL_COMPILE_STATUS, success)
success[1] == GL_TRUE
end
# Usage:
glCompileShader(shader)
!validateShader(shader) && println("Shader creation error: ", getInfoLog(shader))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment