From 1dd1403aac8df25988f2b38ad12c8fff23de99af Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 9 Jan 2015 02:28:16 +0900 Subject: [PATCH] Bug fix: opengl.NewBuffer may accept integer value (glfw) --- internal/opengl/context.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/opengl/context.go b/internal/opengl/context.go index 16b9bb66d..bd8ed79e6 100644 --- a/internal/opengl/context.go +++ b/internal/opengl/context.go @@ -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) {