mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
internal/atlas: bug fix: the offscreen must be an independent image
Closes #1938
This commit is contained in:
parent
f51d691d87
commit
0680ca413d
@ -221,6 +221,7 @@ type Image struct {
|
||||
width int
|
||||
height int
|
||||
disposed bool
|
||||
independent bool
|
||||
volatile bool
|
||||
screen bool
|
||||
|
||||
@ -694,6 +695,10 @@ func NewImage(width, height int) *Image {
|
||||
}
|
||||
}
|
||||
|
||||
func (i *Image) SetIndependent(independent bool) {
|
||||
i.independent = independent
|
||||
}
|
||||
|
||||
func (i *Image) SetVolatile(volatile bool) {
|
||||
i.volatile = volatile
|
||||
if i.backend == nil {
|
||||
@ -709,6 +714,9 @@ func (i *Image) canBePutOnAtlas() bool {
|
||||
if minSize == 0 || maxSize == 0 {
|
||||
panic("atlas: minSize or maxSize must be initialized")
|
||||
}
|
||||
if i.independent {
|
||||
return false
|
||||
}
|
||||
if i.volatile {
|
||||
return false
|
||||
}
|
||||
|
@ -65,6 +65,18 @@ func (i *Image) initialize(width, height int) {
|
||||
i.height = height
|
||||
}
|
||||
|
||||
func (i *Image) SetIndependent(volatile bool) {
|
||||
if maybeCanAddDelayedCommand() {
|
||||
if tryAddDelayedCommand(func() error {
|
||||
i.SetIndependent(volatile)
|
||||
return nil
|
||||
}) {
|
||||
return
|
||||
}
|
||||
}
|
||||
i.img.SetIndependent(volatile)
|
||||
}
|
||||
|
||||
func (i *Image) SetVolatile(volatile bool) {
|
||||
if maybeCanAddDelayedCommand() {
|
||||
if tryAddDelayedCommand(func() error {
|
||||
|
@ -59,6 +59,10 @@ func NewScreenFramebufferMipmap(width, height int) *Mipmap {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Mipmap) SetIndependent(volatile bool) {
|
||||
m.orig.SetIndependent(volatile)
|
||||
}
|
||||
|
||||
func (m *Mipmap) SetVolatile(volatile bool) {
|
||||
m.volatile = volatile
|
||||
if m.volatile {
|
||||
|
@ -93,6 +93,12 @@ func (c *uiContext) updateOffscreen() {
|
||||
if c.offscreen == nil {
|
||||
c.offscreen = NewImage(ow, oh)
|
||||
c.offscreen.mipmap.SetVolatile(IsScreenClearedEveryFrame())
|
||||
|
||||
// Keep the offscreen an independent image from an atlas (#1938).
|
||||
// The shader program for the screen is special and doesn't work well with an image on an atlas.
|
||||
// An image on an atlas is surrounded by a transparent edge,
|
||||
// and the shader program unexpectedly picks the pixel on the edges.
|
||||
c.offscreen.mipmap.SetIndependent(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user