diff --git a/internal/graphics/opengl/context.go b/internal/graphics/opengl/context.go index 21786da5a..36bfe0b1c 100644 --- a/internal/graphics/opengl/context.go +++ b/internal/graphics/opengl/context.go @@ -25,6 +25,8 @@ var ( StaticDraw BufferUsage Triangles Mode Lines Mode + Short DataType + Float DataType zero operation one operation diff --git a/internal/graphics/opengl/context_desktop.go b/internal/graphics/opengl/context_desktop.go index 570d9fc22..754cab01d 100644 --- a/internal/graphics/opengl/context_desktop.go +++ b/internal/graphics/opengl/context_desktop.go @@ -57,6 +57,8 @@ func init() { StaticDraw = gl.STATIC_DRAW Triangles = gl.TRIANGLES Lines = gl.LINES + Short = gl.SHORT + Float = gl.FLOAT zero = gl.ZERO one = gl.ONE @@ -432,10 +434,10 @@ func (c *Context) getAttribLocationImpl(p Program, location string) attribLocati return attrib } -func (c *Context) VertexAttribPointer(p Program, location string, size int, normalize bool, stride int, offset int) { +func (c *Context) VertexAttribPointer(p Program, location string, size int, dataType DataType, normalize bool, stride int, offset int) { _ = c.runOnContextThread(func() error { l := c.locationCache.GetAttribLocation(c, p, location) - gl.VertexAttribPointer(uint32(l), int32(size), gl.SHORT, normalize, int32(stride), gl.PtrOffset(offset)) + gl.VertexAttribPointer(uint32(l), int32(size), uint32(dataType), normalize, int32(stride), gl.PtrOffset(offset)) return nil }) } diff --git a/internal/graphics/opengl/context_js.go b/internal/graphics/opengl/context_js.go index d3633df6c..35d67d33a 100644 --- a/internal/graphics/opengl/context_js.go +++ b/internal/graphics/opengl/context_js.go @@ -73,6 +73,8 @@ func init() { StaticDraw = BufferUsage(c.Get("STATIC_DRAW").Int()) Triangles = Mode(c.Get("TRIANGLES").Int()) Lines = Mode(c.Get("LINES").Int()) + Short = DataType(c.Get("SHORT").Int()) + Float = DataType(c.Get("FLOAT").Int()) zero = operation(c.Get("ZERO").Int()) one = operation(c.Get("ONE").Int()) @@ -354,10 +356,10 @@ func (c *Context) getAttribLocationImpl(p Program, location string) attribLocati return attribLocation(gl.GetAttribLocation(p.Object, location)) } -func (c *Context) VertexAttribPointer(p Program, location string, size int, normalize bool, stride int, offset int) { +func (c *Context) VertexAttribPointer(p Program, location string, size int, dataType DataType, normalize bool, stride int, offset int) { gl := c.gl l := c.locationCache.GetAttribLocation(c, p, location) - gl.VertexAttribPointer(int(l), size, gl.SHORT, normalize, stride, offset) + gl.VertexAttribPointer(int(l), size, int(dataType), normalize, stride, offset) } func (c *Context) EnableVertexAttribArray(p Program, location string) { diff --git a/internal/graphics/opengl/context_mobile.go b/internal/graphics/opengl/context_mobile.go index 99fd11180..13a1c9c8b 100644 --- a/internal/graphics/opengl/context_mobile.go +++ b/internal/graphics/opengl/context_mobile.go @@ -54,6 +54,8 @@ func init() { StaticDraw = mgl.STATIC_DRAW Triangles = mgl.TRIANGLES Lines = mgl.LINES + Short = mgl.SHORT + Float = mgl.FLOAT zero = mgl.ZERO one = mgl.ONE @@ -336,10 +338,10 @@ func (c *Context) getAttribLocationImpl(p Program, location string) attribLocati return a } -func (c *Context) VertexAttribPointer(p Program, location string, size int, normalize bool, stride int, offset int) { +func (c *Context) VertexAttribPointer(p Program, location string, size int, dataType DataType, normalize bool, stride int, offset int) { gl := c.gl l := c.locationCache.GetAttribLocation(c, p, location) - gl.VertexAttribPointer(mgl.Attrib(l), size, mgl.SHORT, normalize, stride, offset) + gl.VertexAttribPointer(mgl.Attrib(l), size, mgl.Enum(dataType), normalize, stride, offset) } func (c *Context) EnableVertexAttribArray(p Program, location string) { diff --git a/internal/graphics/opengl/types.go b/internal/graphics/opengl/types.go index ea4cc95f6..94af3da2e 100644 --- a/internal/graphics/opengl/types.go +++ b/internal/graphics/opengl/types.go @@ -22,6 +22,7 @@ type Mode int type operation int type CompositeMode int +type DataType int const ( CompositeModeSourceOver CompositeMode = iota // This value must be 0 (= initial value) diff --git a/internal/graphics/program.go b/internal/graphics/program.go index 1fa6ecbc7..052fdec57 100644 --- a/internal/graphics/program.go +++ b/internal/graphics/program.go @@ -50,7 +50,7 @@ func (a *arrayBufferLayout) enable(c *opengl.Context, program opengl.Program) { offset := 0 for _, p := range a.parts { size := p.unit * p.num - c.VertexAttribPointer(program, p.name, size, p.normalize, total, offset) + c.VertexAttribPointer(program, p.name, size, opengl.Short, p.normalize, total, offset) offset += size } }