mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
opengl: BufferSubData should be able to take generic type
This commit is contained in:
parent
54e5263250
commit
80e3a3497c
@ -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
|
||||
})
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user