func UseProgram(p Program) { defer func() { errstr := errDrain() log.Printf("gl.UseProgram(%v) %v", p, errstr) }() C.glUseProgram(p.c()) }
func (game *game) drawFrame() { time += .05 color := (C.GLclampf(math.Sin(time)) + 1) * .5 C.glUniform2f(C.GLint(game.offsetUni), C.GLfloat(game.offsetX), C.GLfloat(game.offsetY)) C.glUniform3f(C.GLint(game.colorUni), 1.0, C.GLfloat(color), 0) C.glClear(C.GL_COLOR_BUFFER_BIT | C.GL_DEPTH_BUFFER_BIT) C.glUseProgram(game.prog) C.glDrawArrays(C.GL_TRIANGLES, 0, 3) }
func (game *game) initGL() { log.Printf("GL_VERSION: %v GL_RENDERER: %v GL_VENDOR %v\n", GetString(C.GL_VERSION), GetString(C.GL_RENDERER), GetString(C.GL_VENDOR)) log.Printf("GL_EXTENSIONS: %v\n", GetString(C.GL_EXTENSIONS)) C.glClearColor(0.0, 0.0, 0.0, 1.0) C.glEnable(C.GL_CULL_FACE) C.glEnable(C.GL_DEPTH_TEST) game.prog = createProgram(vertShaderSrcDef, fragShaderSrcDef) posAttrib := attribLocation(game.prog, "vPosition") game.offsetUni = uniformLocation(game.prog, "offset") game.colorUni = uniformLocation(game.prog, "color") C.glUseProgram(game.prog) C.glEnableVertexAttribArray(C.GLuint(posAttrib)) vertVBO := GenBuffer() checkGLError() C.glBindBuffer(C.GL_ARRAY_BUFFER, vertVBO) verts := []float32{.0, 0.5, -0.5, -0.5, 0.5, -0.5} C.glBufferData(C.GL_ARRAY_BUFFER, C.GLsizeiptr(len(verts)*int(unsafe.Sizeof(verts[0]))), unsafe.Pointer(&verts[0]), C.GL_STATIC_DRAW) C.glVertexAttribPointer(C.GLuint(posAttrib), 2, C.GL_FLOAT, C.GL_FALSE, 0, unsafe.Pointer(uintptr(0))) }
func UseProgram(p Program) { C.glUseProgram(p.c()) }
func UseProgram( program uint32) { C.glUseProgram( C.GLuint(program)) }
// Unuse calls glUseProgram with a 0 argument func (p *Program) Unuse() { C.glUseProgram(C.GLuint(0)) }
// Use calls glUseProgram func (p *Program) Use() { C.glUseProgram(p.i) }
func (program *Program) Use() { C.glUseProgram(program.id) }
// Use installs a program object as part of current rendering state. func (p Program) Use() { C.glUseProgram(C.GLuint(p)) }
func ProgramUnuse() { C.glUseProgram(C.GLuint(0)) }