opengl: Add DataType

This commit is contained in:
Hajime Hoshi 2016-10-22 14:51:23 +09:00
parent e5e9b178ae
commit 9abeb29d2a
6 changed files with 16 additions and 7 deletions

View File

@ -25,6 +25,8 @@ var (
StaticDraw BufferUsage
Triangles Mode
Lines Mode
Short DataType
Float DataType
zero operation
one operation

View File

@ -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
})
}

View File

@ -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) {

View File

@ -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) {

View File

@ -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)

View File

@ -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
}
}