Skip to content

Commit

Permalink
opengl: Bug fix: Reset the bound framebuffer after deletion (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Jun 3, 2016
1 parent 5684410 commit da1354e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/graphics/opengl/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
c.bindFramebufferImpl(f)
c.lastFramebuffer = f
if c.lastFramebuffer != f {
c.bindFramebufferImpl(f)
c.lastFramebuffer = f
}
}
6 changes: 6 additions & 0 deletions internal/graphics/opengl/context_desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
6 changes: 6 additions & 0 deletions internal/graphics/opengl/context_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
6 changes: 6 additions & 0 deletions internal/graphics/opengl/context_mobile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down

0 comments on commit da1354e

Please sign in to comment.