示例#1
0
文件: renderable.go 项目: fmd/gogol
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
}
示例#2
0
文件: buffer.go 项目: PieterD/crap
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)
}
示例#3
0
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
}
示例#4
0
文件: gl_opengl.go 项目: tanema/amore
// 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)
}
示例#5
0
文件: gl_opengl.go 项目: shibukawa/gl
// 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]))
}
示例#6
0
func (c *Context) BufferSubData(bufferType BufferType, data []int16) {
	const int16Size = 2
	gl.BufferSubData(uint32(bufferType), 0, int16Size*len(data), gl.Ptr(data))
}
示例#7
0
文件: gl_gl2.go 项目: EngoEngine/gl
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))
}
示例#8
0
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
	})
}