Skip to content

Instantly share code, notes, and snippets.

@yurivish yurivish/shaders.jl
Last active Aug 29, 2015

What would you like to do?
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)
function validateShader(shader)
success::Array{GLint, 1} = [0]
glGetShaderiv(shader, GL_COMPILE_STATUS, success)
success[1] == GL_TRUE
# Usage:
!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
You can’t perform that action at this time.