mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
graphics: Bug fix: Copy variables out of the closures
This commit is contained in:
parent
d2312f1450
commit
fc939fabb8
18
image.go
18
image.go
@ -113,8 +113,8 @@ func (i *Image) Fill(clr color.Color) error {
|
|||||||
i.copyCheck()
|
i.copyCheck()
|
||||||
|
|
||||||
if atomic.LoadInt32(&isImageAvailable) == 0 {
|
if atomic.LoadInt32(&isImageAvailable) == 0 {
|
||||||
|
r, g, b, a := clr.RGBA()
|
||||||
enqueueImageOp(func() {
|
enqueueImageOp(func() {
|
||||||
r, g, b, a := clr.RGBA()
|
|
||||||
i.Fill(color.RGBA64{
|
i.Fill(color.RGBA64{
|
||||||
R: uint16(r),
|
R: uint16(r),
|
||||||
G: uint16(g),
|
G: uint16(g),
|
||||||
@ -189,8 +189,8 @@ func (i *Image) DrawImage(img *Image, options *DrawImageOptions) error {
|
|||||||
i.copyCheck()
|
i.copyCheck()
|
||||||
|
|
||||||
if atomic.LoadInt32(&isImageAvailable) == 0 {
|
if atomic.LoadInt32(&isImageAvailable) == 0 {
|
||||||
|
op := *options
|
||||||
enqueueImageOp(func() {
|
enqueueImageOp(func() {
|
||||||
op := *options
|
|
||||||
i.DrawImage(img, &op)
|
i.DrawImage(img, &op)
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
@ -408,12 +408,12 @@ func (i *Image) DrawTriangles(vertices []Vertex, indices []uint16, img *Image, o
|
|||||||
i.copyCheck()
|
i.copyCheck()
|
||||||
|
|
||||||
if atomic.LoadInt32(&isImageAvailable) == 0 {
|
if atomic.LoadInt32(&isImageAvailable) == 0 {
|
||||||
|
vs := make([]Vertex, len(vertices))
|
||||||
|
copy(vs, vertices)
|
||||||
|
is := make([]uint16, len(indices))
|
||||||
|
copy(is, indices)
|
||||||
|
op := *options
|
||||||
enqueueImageOp(func() {
|
enqueueImageOp(func() {
|
||||||
vs := make([]Vertex, len(vertices))
|
|
||||||
copy(vs, vertices)
|
|
||||||
is := make([]uint16, len(indices))
|
|
||||||
copy(is, indices)
|
|
||||||
op := *options
|
|
||||||
i.DrawTriangles(vs, is, img, &op)
|
i.DrawTriangles(vs, is, img, &op)
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
@ -652,9 +652,9 @@ func (i *Image) ReplacePixels(p []byte) error {
|
|||||||
i.copyCheck()
|
i.copyCheck()
|
||||||
|
|
||||||
if atomic.LoadInt32(&isImageAvailable) == 0 {
|
if atomic.LoadInt32(&isImageAvailable) == 0 {
|
||||||
|
px := make([]byte, len(p))
|
||||||
|
copy(px, p)
|
||||||
enqueueImageOp(func() {
|
enqueueImageOp(func() {
|
||||||
px := make([]byte, len(p))
|
|
||||||
copy(px, p)
|
|
||||||
i.ReplacePixels(px)
|
i.ReplacePixels(px)
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user