Bug fix: opengl.NewBuffer may accept integer value (glfw)

This commit is contained in:
Hajime Hoshi 2015-01-09 02:28:16 +09:00
parent 636ae84ad5
commit 1dd1403aac

View File

@ -208,7 +208,11 @@ func (c *Context) DisableVertexAttribArray(p Program, location string) {
func (c *Context) NewBuffer(bufferType BufferType, v interface{}, bufferUsageType BufferUsageType) {
gl.GenBuffer().Bind(gl.GLenum(bufferType))
size := 0
ptr := v
switch v := v.(type) {
case int:
size = v
ptr = nil
case []uint16:
size = 2 * len(v)
case []float32:
@ -216,7 +220,7 @@ func (c *Context) NewBuffer(bufferType BufferType, v interface{}, bufferUsageTyp
default:
panic("not reach")
}
gl.BufferData(gl.GLenum(bufferType), size, v, gl.GLenum(bufferUsageType))
gl.BufferData(gl.GLenum(bufferType), size, ptr, gl.GLenum(bufferUsageType))
}
func (c *Context) BufferSubData(bufferType BufferType, data []float32) {