mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-23 09:22:01 +01:00
graphics: Remove fillCommand
This commit is contained in:
parent
fe7aae32a0
commit
b58dc26832
@ -18,8 +18,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/color"
|
||||
"math"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/affine"
|
||||
emath "github.com/hajimehoshi/ebiten/internal/math"
|
||||
@ -186,38 +184,6 @@ func FlushCommands() error {
|
||||
return theCommandQueue.Flush()
|
||||
}
|
||||
|
||||
// fillCommand represents a drawing command to fill an image with a solid color.
|
||||
type fillCommand struct {
|
||||
dst *Image
|
||||
color color.RGBA
|
||||
}
|
||||
|
||||
// Exec executes the fillCommand.
|
||||
func (c *fillCommand) Exec(indexOffsetInBytes int) error {
|
||||
f, err := c.dst.createFramebufferIfNeeded()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
f.setAsViewport()
|
||||
|
||||
cr, cg, cb, ca := c.color.R, c.color.G, c.color.B, c.color.A
|
||||
const max = math.MaxUint8
|
||||
r := float32(cr) / max
|
||||
g := float32(cg) / max
|
||||
b := float32(cb) / max
|
||||
a := float32(ca) / max
|
||||
if err := opengl.GetContext().FillFramebuffer(r, g, b, a); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Flush is needed after filling (#419)
|
||||
opengl.GetContext().Flush()
|
||||
// Mysterious, but binding texture is needed after filling
|
||||
// on some mechines like Photon 2 (#492).
|
||||
opengl.GetContext().BindTexture(opengl.InvalidTexture)
|
||||
return nil
|
||||
}
|
||||
|
||||
// drawImageCommand represents a drawing command to draw an image on another image.
|
||||
type drawImageCommand struct {
|
||||
dst *Image
|
||||
|
@ -87,17 +87,6 @@ func (i *Image) Size() (int, int) {
|
||||
return i.width, i.height
|
||||
}
|
||||
|
||||
func (i *Image) Fill(r, g, b, a uint8) {
|
||||
c := &fillCommand{
|
||||
dst: i,
|
||||
}
|
||||
c.color.R = r
|
||||
c.color.G = g
|
||||
c.color.B = b
|
||||
c.color.A = a
|
||||
theCommandQueue.Enqueue(c)
|
||||
}
|
||||
|
||||
func (i *Image) DrawImage(src *Image, vertices []float32, clr *affine.ColorM, mode opengl.CompositeMode, filter Filter) {
|
||||
theCommandQueue.EnqueueDrawImageCommand(i, src, vertices, clr, mode, filter)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user