From 80e3a3497ce0031b7653feb403c277b4b7941e81 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 22 Oct 2016 03:21:53 +0900 Subject: [PATCH] opengl: BufferSubData should be able to take generic type --- internal/graphics/opengl/context_desktop.go | 9 +++++++-- internal/graphics/opengl/context_js.go | 9 +++++++-- internal/graphics/opengl/context_mobile.go | 9 +++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/internal/graphics/opengl/context_desktop.go b/internal/graphics/opengl/context_desktop.go index b59d5ef6f..07d1cb4f3 100644 --- a/internal/graphics/opengl/context_desktop.go +++ b/internal/graphics/opengl/context_desktop.go @@ -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 }) } diff --git a/internal/graphics/opengl/context_js.go b/internal/graphics/opengl/context_js.go index ca3620d21..97189c5ec 100644 --- a/internal/graphics/opengl/context_js.go +++ b/internal/graphics/opengl/context_js.go @@ -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) { diff --git a/internal/graphics/opengl/context_mobile.go b/internal/graphics/opengl/context_mobile.go index e0f043f37..4bcb7aa0c 100644 --- a/internal/graphics/opengl/context_mobile.go +++ b/internal/graphics/opengl/context_mobile.go @@ -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) {