opengl: BufferSubData should be able to take generic type

This commit is contained in:
Hajime Hoshi 2016-10-22 03:21:53 +09:00
parent 54e5263250
commit 80e3a3497c
3 changed files with 21 additions and 6 deletions

View File

@ -483,9 +483,14 @@ func (c *Context) BindElementArrayBuffer(b Buffer) {
})
}
func (c *Context) BufferSubData(bufferType BufferType, data []int16) {
func (c *Context) BufferSubData(bufferType BufferType, data interface{}) {
_ = c.runOnContextThread(func() error {
gl.BufferSubData(uint32(bufferType), 0, 2*len(data), gl.Ptr(data))
switch data := data.(type) {
case []int16:
gl.BufferSubData(uint32(bufferType), 0, 2*len(data), gl.Ptr(data))
default:
panic("not reach")
}
return nil
})
}

View File

@ -385,9 +385,14 @@ func (c *Context) BindElementArrayBuffer(b Buffer) {
gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, b.Object)
}
func (c *Context) BufferSubData(bufferType BufferType, data []int16) {
func (c *Context) BufferSubData(bufferType BufferType, data interface{}) {
gl := c.gl
gl.BufferSubData(int(bufferType), 0, data)
switch data := data.(type) {
case []int16:
gl.BufferSubData(int(bufferType), 0, data)
default:
panic("not reach")
}
}
func (c *Context) DeleteBuffer(b Buffer) {

View File

@ -392,9 +392,14 @@ func (c *Context) BindElementArrayBuffer(b Buffer) {
gl.BindBuffer(mgl.ELEMENT_ARRAY_BUFFER, mgl.Buffer(b))
}
func (c *Context) BufferSubData(bufferType BufferType, data []int16) {
func (c *Context) BufferSubData(bufferType BufferType, data interface{}) {
gl := c.gl
gl.BufferSubData(mgl.Enum(bufferType), 0, int16ToBytes(data))
switch data := data.(type) {
case []int16:
gl.BufferSubData(mgl.Enum(bufferType), 0, int16ToBytes(data))
default:
panic("not reach")
}
}
func (c *Context) DeleteBuffer(b Buffer) {