mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
opengl: Add DataType
This commit is contained in:
parent
e5e9b178ae
commit
9abeb29d2a
@ -25,6 +25,8 @@ var (
|
|||||||
StaticDraw BufferUsage
|
StaticDraw BufferUsage
|
||||||
Triangles Mode
|
Triangles Mode
|
||||||
Lines Mode
|
Lines Mode
|
||||||
|
Short DataType
|
||||||
|
Float DataType
|
||||||
|
|
||||||
zero operation
|
zero operation
|
||||||
one operation
|
one operation
|
||||||
|
@ -57,6 +57,8 @@ func init() {
|
|||||||
StaticDraw = gl.STATIC_DRAW
|
StaticDraw = gl.STATIC_DRAW
|
||||||
Triangles = gl.TRIANGLES
|
Triangles = gl.TRIANGLES
|
||||||
Lines = gl.LINES
|
Lines = gl.LINES
|
||||||
|
Short = gl.SHORT
|
||||||
|
Float = gl.FLOAT
|
||||||
|
|
||||||
zero = gl.ZERO
|
zero = gl.ZERO
|
||||||
one = gl.ONE
|
one = gl.ONE
|
||||||
@ -432,10 +434,10 @@ func (c *Context) getAttribLocationImpl(p Program, location string) attribLocati
|
|||||||
return attrib
|
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 {
|
_ = c.runOnContextThread(func() error {
|
||||||
l := c.locationCache.GetAttribLocation(c, p, location)
|
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
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,8 @@ func init() {
|
|||||||
StaticDraw = BufferUsage(c.Get("STATIC_DRAW").Int())
|
StaticDraw = BufferUsage(c.Get("STATIC_DRAW").Int())
|
||||||
Triangles = Mode(c.Get("TRIANGLES").Int())
|
Triangles = Mode(c.Get("TRIANGLES").Int())
|
||||||
Lines = Mode(c.Get("LINES").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())
|
zero = operation(c.Get("ZERO").Int())
|
||||||
one = operation(c.Get("ONE").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))
|
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
|
gl := c.gl
|
||||||
l := c.locationCache.GetAttribLocation(c, p, location)
|
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) {
|
func (c *Context) EnableVertexAttribArray(p Program, location string) {
|
||||||
|
@ -54,6 +54,8 @@ func init() {
|
|||||||
StaticDraw = mgl.STATIC_DRAW
|
StaticDraw = mgl.STATIC_DRAW
|
||||||
Triangles = mgl.TRIANGLES
|
Triangles = mgl.TRIANGLES
|
||||||
Lines = mgl.LINES
|
Lines = mgl.LINES
|
||||||
|
Short = mgl.SHORT
|
||||||
|
Float = mgl.FLOAT
|
||||||
|
|
||||||
zero = mgl.ZERO
|
zero = mgl.ZERO
|
||||||
one = mgl.ONE
|
one = mgl.ONE
|
||||||
@ -336,10 +338,10 @@ func (c *Context) getAttribLocationImpl(p Program, location string) attribLocati
|
|||||||
return a
|
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
|
gl := c.gl
|
||||||
l := c.locationCache.GetAttribLocation(c, p, location)
|
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) {
|
func (c *Context) EnableVertexAttribArray(p Program, location string) {
|
||||||
|
@ -22,6 +22,7 @@ type Mode int
|
|||||||
type operation int
|
type operation int
|
||||||
|
|
||||||
type CompositeMode int
|
type CompositeMode int
|
||||||
|
type DataType int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
CompositeModeSourceOver CompositeMode = iota // This value must be 0 (= initial value)
|
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
|
offset := 0
|
||||||
for _, p := range a.parts {
|
for _, p := range a.parts {
|
||||||
size := p.unit * p.num
|
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
|
offset += size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user