mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
opengl: Bug fix: glViewport must be called after framebuffer deletion
This commit is contained in:
parent
37473d2f9f
commit
12904d168d
@ -35,15 +35,16 @@ type Context struct {
|
||||
oneMinusDstAlpha operation
|
||||
locationCache *locationCache
|
||||
lastFramebuffer Framebuffer
|
||||
lastViewportWidth int
|
||||
lastViewportHeight int
|
||||
lastCompositeMode CompositeMode
|
||||
context
|
||||
}
|
||||
|
||||
func (c *Context) bindFramebuffer(f Framebuffer) bool {
|
||||
if c.lastFramebuffer != f {
|
||||
func (c *Context) bindFramebuffer(f Framebuffer) {
|
||||
if c.lastFramebuffer == f {
|
||||
return
|
||||
}
|
||||
c.bindFramebufferImpl(f)
|
||||
c.lastFramebuffer = f
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -228,8 +228,11 @@ func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) {
|
||||
|
||||
func (c *Context) SetViewport(f Framebuffer, width, height int) error {
|
||||
return c.RunOnContextThread(func() error {
|
||||
if c.bindFramebuffer(f) {
|
||||
c.bindFramebuffer(f)
|
||||
if c.lastViewportWidth != width || c.lastViewportHeight != height {
|
||||
gl.Viewport(0, 0, int32(width), int32(height))
|
||||
c.lastViewportWidth = width
|
||||
c.lastViewportHeight = height
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
@ -205,9 +205,12 @@ func (c *Context) NewFramebuffer(t Texture) (Framebuffer, error) {
|
||||
}
|
||||
|
||||
func (c *Context) SetViewport(f Framebuffer, width, height int) error {
|
||||
if c.bindFramebuffer(f) {
|
||||
c.bindFramebuffer(f)
|
||||
if c.lastViewportWidth != width || c.lastViewportHeight != height {
|
||||
gl := c.gl
|
||||
gl.Viewport(0, 0, width, height)
|
||||
c.lastViewportWidth = width
|
||||
c.lastViewportHeight = height
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -182,9 +182,12 @@ func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) {
|
||||
}
|
||||
|
||||
func (c *Context) SetViewport(f Framebuffer, width, height int) error {
|
||||
if c.bindFramebuffer(f) {
|
||||
c.bindFramebuffer(f)
|
||||
if c.lastViewportWidth != width || c.lastViewportHeight != height {
|
||||
gl := c.gl
|
||||
gl.Viewport(0, 0, width, height)
|
||||
c.lastViewportWidth = width
|
||||
c.lastViewportHeight = height
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -203,6 +206,8 @@ func (c *Context) DeleteFramebuffer(f Framebuffer) {
|
||||
// https://www.khronos.org/opengles/sdk/docs/man/xhtml/glDeleteFramebuffers.xml
|
||||
if c.lastFramebuffer == f {
|
||||
c.lastFramebuffer = ZeroFramebuffer
|
||||
c.lastViewportWidth = 0
|
||||
c.lastViewportHeight = 0
|
||||
}
|
||||
gl.DeleteFramebuffer(mgl.Framebuffer(f))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user