Skip to content
chsc edited this page Jan 15, 2012 · 1 revision

String Handling

Pass an array of strings to ShaderSource

Sample:

vertexShader := gl.CreateShader(gl.VERTEX_SHADER)
vertexShaderGLStrs := gl.GLStringArray(vertexShaderStr1, vertexShaderStr2, ...)
defer gl.GLStringArrayFree(vertexShaderGLStrs)
gl.ShaderSource(vertexShader, len(vertexShaderGLStrs), &vertexShaderGLStrs[0], nil)
gl.CompileShader(vertexShader)

Get shader info log message

Sample:

var length gl.Int
gl.GetShaderiv(fragmentShader, gl.INFO_LOG_LENGTH, &length)
glString := gl.GLStringAlloc(gl.Sizei(length))
defer gl.GLStringFree(glString)
gl.GetShaderInfoLog(fragmentShader, gl.Sizei(length), nil, glString)
fmt.Println("shader log: ", gl.GoString(glString))

Maybe future versions of GoGL will have a more convenient interface for some special functions. Any idea is appreciated.