mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18: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
|
oneMinusDstAlpha operation
|
||||||
locationCache *locationCache
|
locationCache *locationCache
|
||||||
lastFramebuffer Framebuffer
|
lastFramebuffer Framebuffer
|
||||||
|
lastViewportWidth int
|
||||||
|
lastViewportHeight int
|
||||||
lastCompositeMode CompositeMode
|
lastCompositeMode CompositeMode
|
||||||
context
|
context
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) bindFramebuffer(f Framebuffer) bool {
|
func (c *Context) bindFramebuffer(f Framebuffer) {
|
||||||
if c.lastFramebuffer != f {
|
if c.lastFramebuffer == f {
|
||||||
|
return
|
||||||
|
}
|
||||||
c.bindFramebufferImpl(f)
|
c.bindFramebufferImpl(f)
|
||||||
c.lastFramebuffer = 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 {
|
func (c *Context) SetViewport(f Framebuffer, width, height int) error {
|
||||||
return c.RunOnContextThread(func() 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))
|
gl.Viewport(0, 0, int32(width), int32(height))
|
||||||
|
c.lastViewportWidth = width
|
||||||
|
c.lastViewportHeight = height
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
@ -205,9 +205,12 @@ func (c *Context) NewFramebuffer(t Texture) (Framebuffer, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) SetViewport(f Framebuffer, width, height int) 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 := c.gl
|
||||||
gl.Viewport(0, 0, width, height)
|
gl.Viewport(0, 0, width, height)
|
||||||
|
c.lastViewportWidth = width
|
||||||
|
c.lastViewportHeight = height
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -182,9 +182,12 @@ func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) SetViewport(f Framebuffer, width, height int) 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 := c.gl
|
||||||
gl.Viewport(0, 0, width, height)
|
gl.Viewport(0, 0, width, height)
|
||||||
|
c.lastViewportWidth = width
|
||||||
|
c.lastViewportHeight = height
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -203,6 +206,8 @@ func (c *Context) DeleteFramebuffer(f Framebuffer) {
|
|||||||
// https://www.khronos.org/opengles/sdk/docs/man/xhtml/glDeleteFramebuffers.xml
|
// https://www.khronos.org/opengles/sdk/docs/man/xhtml/glDeleteFramebuffers.xml
|
||||||
if c.lastFramebuffer == f {
|
if c.lastFramebuffer == f {
|
||||||
c.lastFramebuffer = ZeroFramebuffer
|
c.lastFramebuffer = ZeroFramebuffer
|
||||||
|
c.lastViewportWidth = 0
|
||||||
|
c.lastViewportHeight = 0
|
||||||
}
|
}
|
||||||
gl.DeleteFramebuffer(mgl.Framebuffer(f))
|
gl.DeleteFramebuffer(mgl.Framebuffer(f))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user