Пример #1
0
func initShader(gl *webgl.Context, canvas *js.Object) (*js.Object, bool) {
	shader := gl.CreateProgram()
	vertexShader, ok := getShader(gl, gl.VERTEX_SHADER, vertexShaderSource)
	if !ok {
		js.Global.Call("alert", "Error getting vertex shader")
		return nil, false
	}
	fragShader, ok := getShader(gl, gl.FRAGMENT_SHADER, fragShaderSource)
	if !ok {
		js.Global.Call("alert", "Error getting fragment shader")
		return nil, false
	}
	gl.AttachShader(shader, vertexShader)
	gl.AttachShader(shader, fragShader)
	gl.LinkProgram(shader)
	if !gl.GetProgramParameterb(shader, gl.LINK_STATUS) {
		js.Global.Call("alert", "couldnt init shaders :(")
		return nil, false
	}
	gl.UseProgram(shader)

	return shader, true
}