mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
parent
4a5420d6f2
commit
c2fab6cca3
@ -563,7 +563,7 @@ func TestImageEdge(t *testing.T) {
|
||||
|
||||
// Issue #419
|
||||
func TestImageTooManyFill(t *testing.T) {
|
||||
const width = 256
|
||||
const width = 1024
|
||||
|
||||
src, _ := NewImage(1, 1, FilterNearest)
|
||||
dst, _ := NewImage(width, 1, FilterNearest)
|
||||
|
@ -201,10 +201,32 @@ func (c *fillCommand) Exec(indexOffsetInBytes int) error {
|
||||
|
||||
cr, cg, cb, ca := c.color.R, c.color.G, c.color.B, c.color.A
|
||||
const max = math.MaxUint8
|
||||
r := float64(cr) / max
|
||||
g := float64(cg) / max
|
||||
b := float64(cb) / max
|
||||
a := float64(ca) / max
|
||||
r := float32(cr) / max
|
||||
g := float32(cg) / max
|
||||
b := float32(cb) / max
|
||||
a := float32(ca) / max
|
||||
|
||||
// On some machines like MacBook Pro, exact 0 and exact 1 might cause problems
|
||||
// at glClear() (#452).
|
||||
if r == 0 {
|
||||
r = math.Nextafter32(r, 1)
|
||||
}
|
||||
if g == 0 {
|
||||
g = math.Nextafter32(g, 1)
|
||||
}
|
||||
if b == 0 {
|
||||
b = math.Nextafter32(b, 1)
|
||||
}
|
||||
if r == 1 {
|
||||
r = math.Nextafter32(r, 0)
|
||||
}
|
||||
if g == 1 {
|
||||
g = math.Nextafter32(g, 0)
|
||||
}
|
||||
if b == 1 {
|
||||
b = math.Nextafter32(b, 0)
|
||||
}
|
||||
|
||||
if err := opengl.GetContext().FillFramebuffer(r, g, b, a); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -281,9 +281,9 @@ func (c *Context) setViewportImpl(width, height int) {
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Context) FillFramebuffer(r, g, b, a float64) error {
|
||||
func (c *Context) FillFramebuffer(r, g, b, a float32) error {
|
||||
return c.runOnContextThread(func() error {
|
||||
gl.ClearColor(float32(r), float32(g), float32(b), float32(a))
|
||||
gl.ClearColor(r, g, b, a)
|
||||
gl.Clear(gl.COLOR_BUFFER_BIT)
|
||||
return nil
|
||||
})
|
||||
|
@ -252,10 +252,10 @@ func (c *Context) setViewportImpl(width, height int) {
|
||||
gl.Viewport(0, 0, width, height)
|
||||
}
|
||||
|
||||
func (c *Context) FillFramebuffer(r, g, b, a float64) error {
|
||||
func (c *Context) FillFramebuffer(r, g, b, a float32) error {
|
||||
// TODO: Use f?
|
||||
gl := c.gl
|
||||
gl.ClearColor(float32(r), float32(g), float32(b), float32(a))
|
||||
gl.ClearColor(r, g, b, a)
|
||||
gl.Clear(gl.COLOR_BUFFER_BIT)
|
||||
return nil
|
||||
}
|
||||
|
@ -220,9 +220,9 @@ func (c *Context) setViewportImpl(width, height int) {
|
||||
gl.Viewport(0, 0, width, height)
|
||||
}
|
||||
|
||||
func (c *Context) FillFramebuffer(r, g, b, a float64) error {
|
||||
func (c *Context) FillFramebuffer(r, g, b, a float32) error {
|
||||
gl := c.gl
|
||||
gl.ClearColor(float32(r), float32(g), float32(b), float32(a))
|
||||
gl.ClearColor(r, g, b, a)
|
||||
gl.Clear(mgl.COLOR_BUFFER_BIT)
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user