mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
graphicsdriver/opengl: Refactoring
This commit is contained in:
parent
9a49501957
commit
912e13071f
@ -374,15 +374,15 @@ func (c *context) uniformFloats(p program, location string, v []float32, typ sha
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *context) vertexAttribPointer(p program, index int, size int, stride int, offset int) {
|
||||
func (c *context) vertexAttribPointer(index int, size int, stride int, offset int) {
|
||||
gl.VertexAttribPointer(uint32(index), int32(size), gl.FLOAT, false, int32(stride), uintptr(offset))
|
||||
}
|
||||
|
||||
func (c *context) enableVertexAttribArray(p program, index int) {
|
||||
func (c *context) enableVertexAttribArray(index int) {
|
||||
gl.EnableVertexAttribArray(uint32(index))
|
||||
}
|
||||
|
||||
func (c *context) disableVertexAttribArray(p program, index int) {
|
||||
func (c *context) disableVertexAttribArray(index int) {
|
||||
gl.DisableVertexAttribArray(uint32(index))
|
||||
}
|
||||
|
||||
|
@ -410,17 +410,17 @@ func (c *context) uniformFloats(p program, location string, v []float32, typ sha
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *context) vertexAttribPointer(p program, index int, size int, stride int, offset int) {
|
||||
func (c *context) vertexAttribPointer(index int, size int, stride int, offset int) {
|
||||
gl := c.gl
|
||||
gl.Call("vertexAttribPointer", index, size, gles.FLOAT, false, stride, offset)
|
||||
}
|
||||
|
||||
func (c *context) enableVertexAttribArray(p program, index int) {
|
||||
func (c *context) enableVertexAttribArray(index int) {
|
||||
gl := c.gl
|
||||
gl.Call("enableVertexAttribArray", index)
|
||||
}
|
||||
|
||||
func (c *context) disableVertexAttribArray(p program, index int) {
|
||||
func (c *context) disableVertexAttribArray(index int) {
|
||||
gl := c.gl
|
||||
gl.Call("disableVertexAttribArray", index)
|
||||
}
|
||||
|
@ -343,15 +343,15 @@ func (c *context) uniformFloats(p program, location string, v []float32, typ sha
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *context) vertexAttribPointer(p program, index int, size int, stride int, offset int) {
|
||||
func (c *context) vertexAttribPointer(index int, size int, stride int, offset int) {
|
||||
c.ctx.VertexAttribPointer(uint32(index), int32(size), gles.FLOAT, false, int32(stride), offset)
|
||||
}
|
||||
|
||||
func (c *context) enableVertexAttribArray(p program, index int) {
|
||||
func (c *context) enableVertexAttribArray(index int) {
|
||||
c.ctx.EnableVertexAttribArray(uint32(index))
|
||||
}
|
||||
|
||||
func (c *context) disableVertexAttribArray(p program, index int) {
|
||||
func (c *context) disableVertexAttribArray(index int) {
|
||||
c.ctx.DisableVertexAttribArray(uint32(index))
|
||||
}
|
||||
|
||||
|
@ -67,24 +67,24 @@ func (a *arrayBufferLayout) newArrayBuffer(context *context) buffer {
|
||||
return context.newArrayBuffer(a.totalBytes() * graphics.IndicesNum)
|
||||
}
|
||||
|
||||
// enable binds the array buffer the given program to use the array buffer.
|
||||
func (a *arrayBufferLayout) enable(context *context, program program) {
|
||||
// enable starts using the array buffer.
|
||||
func (a *arrayBufferLayout) enable(context *context) {
|
||||
for i := range a.parts {
|
||||
context.enableVertexAttribArray(program, i)
|
||||
context.enableVertexAttribArray(i)
|
||||
}
|
||||
total := a.totalBytes()
|
||||
offset := 0
|
||||
for i, p := range a.parts {
|
||||
context.vertexAttribPointer(program, i, p.num, total, offset)
|
||||
context.vertexAttribPointer(i, p.num, total, offset)
|
||||
offset += floatSizeInBytes * p.num
|
||||
}
|
||||
}
|
||||
|
||||
// disable stops using the array buffer.
|
||||
func (a *arrayBufferLayout) disable(context *context, program program) {
|
||||
func (a *arrayBufferLayout) disable(context *context) {
|
||||
// TODO: Disabling should be done in reversed order?
|
||||
for i := range a.parts {
|
||||
context.disableVertexAttribArray(program, i)
|
||||
context.disableVertexAttribArray(i)
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,7 +253,7 @@ func (g *Graphics) useProgram(program program, uniforms []uniformVariable, textu
|
||||
if !g.state.lastProgram.equal(program) {
|
||||
g.context.useProgram(program)
|
||||
if g.state.lastProgram.equal(zeroProgram) {
|
||||
theArrayBufferLayout.enable(&g.context, program)
|
||||
theArrayBufferLayout.enable(&g.context)
|
||||
g.context.bindArrayBuffer(g.state.arrayBuffer)
|
||||
g.context.bindElementArrayBuffer(g.state.elementArrayBuffer)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user