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
@ -218,11 +218,12 @@ func init() {
|
|||||||
|
|
||||||
// Image is a renctangle pixel set that might be on an atlas.
|
// Image is a renctangle pixel set that might be on an atlas.
|
||||||
type Image struct {
|
type Image struct {
|
||||||
width int
|
width int
|
||||||
height int
|
height int
|
||||||
disposed bool
|
disposed bool
|
||||||
volatile bool
|
independent bool
|
||||||
screen bool
|
volatile bool
|
||||||
|
screen bool
|
||||||
|
|
||||||
backend *backend
|
backend *backend
|
||||||
|
|
||||||
@ -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) {
|
func (i *Image) SetVolatile(volatile bool) {
|
||||||
i.volatile = volatile
|
i.volatile = volatile
|
||||||
if i.backend == nil {
|
if i.backend == nil {
|
||||||
@ -709,6 +714,9 @@ func (i *Image) canBePutOnAtlas() bool {
|
|||||||
if minSize == 0 || maxSize == 0 {
|
if minSize == 0 || maxSize == 0 {
|
||||||
panic("atlas: minSize or maxSize must be initialized")
|
panic("atlas: minSize or maxSize must be initialized")
|
||||||
}
|
}
|
||||||
|
if i.independent {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if i.volatile {
|
if i.volatile {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,18 @@ func (i *Image) initialize(width, height int) {
|
|||||||
i.height = height
|
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) {
|
func (i *Image) SetVolatile(volatile bool) {
|
||||||
if maybeCanAddDelayedCommand() {
|
if maybeCanAddDelayedCommand() {
|
||||||
if tryAddDelayedCommand(func() error {
|
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) {
|
func (m *Mipmap) SetVolatile(volatile bool) {
|
||||||
m.volatile = volatile
|
m.volatile = volatile
|
||||||
if m.volatile {
|
if m.volatile {
|
||||||
|
@ -93,6 +93,12 @@ func (c *uiContext) updateOffscreen() {
|
|||||||
if c.offscreen == nil {
|
if c.offscreen == nil {
|
||||||
c.offscreen = NewImage(ow, oh)
|
c.offscreen = NewImage(ow, oh)
|
||||||
c.offscreen.mipmap.SetVolatile(IsScreenClearedEveryFrame())
|
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