opengl: Bug fix: Reset the bound framebuffer after deletion (#227)

This commit is contained in:
Hajime Hoshi 2016-06-04 03:40:56 +09:00
parent 56844100c2
commit da1354ec51
4 changed files with 22 additions and 4 deletions

View File

@ -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
}
}

View File

@ -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
})

View File

@ -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)
}

View File

@ -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))
}