// Pointer defines an array of generic vertex attribute data. func (l VertexAttribArray) Pointer(sz int, t DataType, norm bool, stride, offs int) { n := 0 if norm { n = 1 } C.glVertexAttribPointer(C.GLuint(l), C.GLint(sz), C.GLenum(t), C.GLboolean(n), C.GLsizei(stride), unsafe.Pointer(uintptr(offs))) }
// VertexAttribSlice uses glVertexAttribPointer to bind an element of the currently // bound buffer at the given index. In order to be able to determine the layout of // the buffer, you need to pass in an uninitialized element of the slice used to fill // the buffer. If dummy is a struct, the value you pass as dummy_index determines // which member of dummy to bind at attribute index. // // e.g., // // VertexAttribSlice(1, false, int32(0), 0) // // to bind an int32 slice to attrib 1, or, // // VertexAttribSlice(3, true, s{}, 1) // // to bind the 1st element in struct s to attrib 3 // // Precondition: VBO bound to ARRAY_BUFFER target containing data of array type dummy func VertexAttribSlice(index uint, normalized bool, dummy interface{}, dummy_index int) error { data, err := sliceAttrib(dummy, dummy_index) if err != nil { return err } C.glVertexAttribPointer(C.GLuint(index), C.GLint(data.Elements), C.GLenum(data.Gltype), glBool(normalized), C.GLsizei(data.Stride), unsafe.Pointer(data.Offset)) return nil }
func VertexAttribPointer(dst Attrib, size int, ty Enum, normalized bool, stride, offset int) { defer func() { errstr := errDrain() log.Printf("gl.VertexAttribPointer(%v, %v, %v, %v, %v, %v) %v", dst, size, ty, normalized, stride, offset, errstr) }() n := glBoolean(normalized) s := C.GLsizei(stride) C.glVertexAttribPointer(dst.c(), C.GLint(size), ty.c(), n, s, unsafe.Pointer(uintptr(offset))) }
func VertexAttribPointer( indx uint32, size int32, type_ Enum, normalized bool, stride Sizei, ptr Void) { C.glVertexAttribPointer( C.GLuint(indx), C.GLint(size), C.GLenum(type_), glBoolean(normalized), C.GLsizei(stride), unsafe.Pointer(ptr)) }
// EnableAttrib calls glEnableVertexAttribArray and glVertexAttribPointer to activate an attribute and connect it to a buffer object. // offset specifies the first vertex, stride specifies the distance from the beginning of one vertex to the next, size specifies the number of components in a vertex (all these arguments are in units of array elements, not bytes like the underlying API). // The byte offset of component j of vertex i is thus calculated as: sizeof(data[0]) * (offset + stride * i + j), where data is the parameter passed to Buffer.Set func (p *Program) EnableAttrib(loc string, buf *Buffer, offset int, size int, stride int, norm bool) { n := FALSE if norm { n = TRUE } buf.Bind(ARRAY_BUFFER) attr := p.attr[loc] C.glEnableVertexAttribArray(attr) C.glVertexAttribPointer(attr, C.GLint(size), buf.t, C.GLboolean(n), C.GLsizei(stride*buf.ts), unsafe.Pointer(uintptr(buf.ts*offset))) buf.Unbind(ARRAY_BUFFER) }
func VertexAttribPointer( indx uint32, size int32, type_ Enum, normalized bool, stride Sizei, ptr interface{}) { C.glVertexAttribPointer( C.GLuint(indx), C.GLint(size), C.GLenum(type_), glBoolean(normalized), C.GLsizei(stride), unsafe.Pointer(reflect.ValueOf(ptr).Pointer())) }
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 VertexAttribPointer(dst Attrib, size int, ty Enum, normalized bool, stride int, offset unsafe.Pointer) { n := glBoolean(normalized) s := C.GLsizei(stride) C.glVertexAttribPointer(dst.c(), C.GLint(size), ty.c(), n, s, offset) }
func (indx AttribLocation) AttribPointer(size uint, typ GLenum, normalized bool, stride int, pointer interface{}) { C.glVertexAttribPointer(C.GLuint(indx), C.GLint(size), C.GLenum(typ), glBool(normalized), C.GLsizei(stride), ptr(pointer)) }
func VertexAttribPointer(indx uint, size int, type_ uint, normalized bool, stride int, ptr uintptr) { C.glVertexAttribPointer(C.GLuint(indx), C.GLint(size), C.GLenum(type_), glBoolean(normalized), C.GLsizei(stride), unsafe.Pointer(ptr)) }
func (attrib vattrib) Pointer(size int, stride int, offset uintptr) { C.glVertexAttribPointer(attrib.index, C.GLint(size), C.GL_FLOAT, C.GL_FALSE, C.GLsizei(stride), unsafe.Pointer(offset)) }
func (attrib FloatAttrib) Pointerf(size int, stride int, data []float32) { C.glVertexAttribPointer(attrib.index, C.GLint(size), C.GL_FLOAT, C.GL_FALSE, C.GLsizei(stride), unsafe.Pointer(&data[0])) }