func NewRenderable(verts []float32) *Renderable { r := &Renderable{ VboPosition: G.Renderer.NewVboPosition(verts), Length: len(verts), } gl.BindBuffer(gl.ARRAY_BUFFER, r.VboPosition.Vbo.Id) gl.BufferSubData(gl.ARRAY_BUFFER, int(r.VboPosition.Index*4), len(verts)*4, gl.Ptr(verts)) return r }
func (buffer *Buffer) Update(offset int, idata interface{}) { data, err := resolveData(idata) if err != nil { panic(err) } if data.typ != buffer.data.typ { panic(fmt.Errorf("buffer data type mismatch: %04X and %04X", buffer.data.typ, data.typ)) } gl.BindBuffer(buffer.bindpoint, buffer.id) defer gl.BindBuffer(buffer.bindpoint, 0) gl.BufferSubData(buffer.bindpoint, offset*data.siz, data.length*data.siz, data.ptr) }
func CreateQuad(opts QuadOpts) *GameObject { halfWidth := opts.Width / 2 halfHeight := opts.Height / 2 verts := []float32{ -halfWidth, -halfHeight, -halfWidth, halfHeight, halfWidth, halfHeight, halfWidth, -halfHeight, } g := &GameObject{ Transform: NewTransform(nil), VboPosition: G.Renderer.GetNewVboPosition(verts), Vertices: verts, } gl.BindBuffer(gl.ARRAY_BUFFER, g.VboPosition.Vbo.Id) gl.BufferSubData(gl.ARRAY_BUFFER, int(g.VboPosition.Index*4), len(g.Vertices)*4, gl.Ptr(g.Vertices)) G.Renderer.GameObjects = append(G.Renderer.GameObjects, g) return g }
// BufferSubData sets some of data in the bound buffer object. // // http://www.khronos.org/opengles/sdk/docs/man3/html/glBufferSubData.xhtml func BufferSubData(target Enum, offset, size int, data unsafe.Pointer) { gl.BufferSubData(uint32(target), offset, size, data) }
// BufferSubData sets some of data in the bound buffer object. // // http://www.khronos.org/opengles/sdk/docs/man3/html/glBufferSubData.xhtml func BufferSubData(target Enum, offset int, data []byte) { gl.BufferSubData(uint32(target), offset, int(len(data)), gl.Ptr(&data[0])) }
func (c *Context) BufferSubData(bufferType BufferType, data []int16) { const int16Size = 2 gl.BufferSubData(uint32(bufferType), 0, int16Size*len(data), gl.Ptr(data)) }
func (c *Context) BufferSubData(target int, offset int, data interface{}) { size := uintptr(reflect.ValueOf(data).Len()) * reflect.TypeOf(data).Elem().Size() gl.BufferSubData(uint32(target), offset, int(size), gl.Ptr(data)) }
func (c *Context) BufferSubData(bufferType BufferType, data []float32) { _ = c.runOnContextThread(func() error { gl.BufferSubData(uint32(bufferType), 0, len(data)*4, gl.Ptr(data)) return nil }) }