func BindBuffer(target Enum, b Buffer) { defer func() { errstr := errDrain() log.Printf("gl.BindBuffer(%v, %v) %v", target, b, errstr) }() C.glBindBuffer(target.c(), b.c()) }
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 BindBuffer(target Enum, b Buffer) { C.glBindBuffer(target.c(), b.c()) }
func BindBuffer( target Enum, buffer uint32) { C.glBindBuffer( C.GLenum(target), C.GLuint(buffer)) }
// Unbind calls glBindBuffer with a 0 argument func (*Buffer) Unbind(targ int) { C.glBindBuffer(C.GLenum(targ), 0) }
// Bind calls glBindBuffer func (buf *Buffer) Bind(targ int) { C.glBindBuffer(C.GLenum(targ), buf.i) }
func BindBuffer(target BufferTarget, buffer Buffer) { C.glBindBuffer(C.GLenum(target), C.GLuint(buffer)) }
// Remove buffer binding func (buffer Buffer) Unbind(target GLenum) { C.glBindBuffer(C.GLenum(target), C.GLuint(0)) }
// Bind binds a named buffer object. func (b Buffer) Bind(targ BufferTarget) { C.glBindBuffer(C.GLenum(targ), C.GLuint(b)) }