mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
opengl: Add DataType
This commit is contained in:
parent
e5e9b178ae
commit
9abeb29d2a
@ -25,6 +25,8 @@ var (
|
||||
StaticDraw BufferUsage
|
||||
Triangles Mode
|
||||
Lines Mode
|
||||
Short DataType
|
||||
Float DataType
|
||||
|
||||
zero operation
|
||||
one operation
|
||||
|
@ -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
|
||||
})
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user