mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
opengl: Bug fix: Reset the bound framebuffer after deletion (#227)
This commit is contained in:
parent
56844100c2
commit
da1354ec51
@ -38,8 +38,8 @@ type Context struct {
|
||||
}
|
||||
|
||||
func (c *Context) bindFramebuffer(f Framebuffer) {
|
||||
// TODO: This is a temporal hack to pass the tests.
|
||||
// Fix the bug (#227).
|
||||
if c.lastFramebuffer != f {
|
||||
c.bindFramebufferImpl(f)
|
||||
c.lastFramebuffer = f
|
||||
}
|
||||
}
|
||||
|
@ -247,6 +247,12 @@ func (c *Context) FillFramebuffer(r, g, b, a float64) error {
|
||||
func (c *Context) DeleteFramebuffer(f Framebuffer) {
|
||||
c.RunOnContextThread(func() error {
|
||||
ff := uint32(f)
|
||||
// If a framebuffer to be delted is bound, a newly bound framebuffer
|
||||
// will be a default framebuffer.
|
||||
// https://www.khronos.org/opengles/sdk/docs/man/xhtml/glDeleteFramebuffers.xml
|
||||
if c.lastFramebuffer == f {
|
||||
c.lastFramebuffer = ZeroFramebuffer
|
||||
}
|
||||
gl.DeleteFramebuffers(1, &ff)
|
||||
return nil
|
||||
})
|
||||
|
@ -223,6 +223,12 @@ func (c *Context) FillFramebuffer(r, g, b, a float64) error {
|
||||
|
||||
func (c *Context) DeleteFramebuffer(f Framebuffer) {
|
||||
gl := c.gl
|
||||
// If a framebuffer to be delted is bound, a newly bound framebuffer
|
||||
// will be a default framebuffer.
|
||||
// https://www.khronos.org/opengles/sdk/docs/man/xhtml/glDeleteFramebuffers.xml
|
||||
if c.lastFramebuffer == f {
|
||||
c.lastFramebuffer = ZeroFramebuffer
|
||||
}
|
||||
gl.DeleteFramebuffer(f.Object)
|
||||
}
|
||||
|
||||
|
@ -199,6 +199,12 @@ func (c *Context) FillFramebuffer(r, g, b, a float64) error {
|
||||
|
||||
func (c *Context) DeleteFramebuffer(f Framebuffer) {
|
||||
gl := c.gl
|
||||
// If a framebuffer to be delted is bound, a newly bound framebuffer
|
||||
// will be a default framebuffer.
|
||||
// https://www.khronos.org/opengles/sdk/docs/man/xhtml/glDeleteFramebuffers.xml
|
||||
if c.lastFramebuffer == f {
|
||||
c.lastFramebuffer = ZeroFramebuffer
|
||||
}
|
||||
gl.DeleteFramebuffer(mgl.Framebuffer(f))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user