Last active
August 29, 2015 14:02
-
-
Save yurivish/7a54e847c2c542fb8da2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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