mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 13:07:26 +01:00
graphicsdriver: Merge UseProgram and DrawElements into Draw
This commit is contained in:
parent
575af7e416
commit
846a719d6c
@ -233,10 +233,9 @@ func (c *drawImageCommand) Exec(indexOffset int) error {
|
|||||||
|
|
||||||
c.dst.image.SetAsDestination()
|
c.dst.image.SetAsDestination()
|
||||||
c.src.image.SetAsSource()
|
c.src.image.SetAsSource()
|
||||||
if err := driver().UseProgram(c.mode, c.color, c.filter); err != nil {
|
if err := driver().Draw(c.nindices, indexOffset, c.mode, c.color, c.filter); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
driver().DrawElements(c.nindices, indexOffset)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,13 +21,12 @@ import (
|
|||||||
|
|
||||||
type GraphicsDriver interface {
|
type GraphicsDriver interface {
|
||||||
BufferSubData(vertices []float32, indices []uint16)
|
BufferSubData(vertices []float32, indices []uint16)
|
||||||
DrawElements(indexLen int, indexOffset int)
|
|
||||||
Flush()
|
Flush()
|
||||||
MaxImageSize() int
|
MaxImageSize() int
|
||||||
NewImage(width, height int) (Image, error)
|
NewImage(width, height int) (Image, error)
|
||||||
NewScreenFramebufferImage(width, height int) Image
|
NewScreenFramebufferImage(width, height int) Image
|
||||||
Reset() error
|
Reset() error
|
||||||
UseProgram(mode graphics.CompositeMode, colorM *affine.ColorM, filter graphics.Filter) error
|
Draw(indexLen int, indexOffset int, mode graphics.CompositeMode, colorM *affine.ColorM, filter graphics.Filter) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type Image interface {
|
type Image interface {
|
||||||
|
@ -91,16 +91,16 @@ func (d *Driver) BufferSubData(vertices []float32, indices []uint16) {
|
|||||||
d.context.elementArrayBufferSubData(indices)
|
d.context.elementArrayBufferSubData(indices)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) UseProgram(mode graphics.CompositeMode, colorM *affine.ColorM, filter graphics.Filter) error {
|
func (d *Driver) Draw(indexLen int, indexOffset int, mode graphics.CompositeMode, colorM *affine.ColorM, filter graphics.Filter) error {
|
||||||
return d.useProgram(mode, colorM, filter)
|
if err := d.useProgram(mode, colorM, filter); err != nil {
|
||||||
}
|
return err
|
||||||
|
}
|
||||||
func (d *Driver) DrawElements(len int, offset int) {
|
d.context.drawElements(indexLen, indexOffset*2) // 2 is uint16 size in bytes
|
||||||
d.context.drawElements(len, offset*2) // 2 is uint16 size in bytes
|
|
||||||
// glFlush() might be necessary at least on MacBook Pro (a smilar problem at #419),
|
// glFlush() might be necessary at least on MacBook Pro (a smilar problem at #419),
|
||||||
// but basically this pass the tests (esp. TestImageTooManyFill).
|
// but basically this pass the tests (esp. TestImageTooManyFill).
|
||||||
// As glFlush() causes performance problems, this should be avoided as much as possible.
|
// As glFlush() causes performance problems, this should be avoided as much as possible.
|
||||||
// Let's wait and see, and file a new issue when this problem is newly found.
|
// Let's wait and see, and file a new issue when this problem is newly found.
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) Flush() {
|
func (d *Driver) Flush() {
|
||||||
|
Loading…
Reference in New Issue
Block a user