opengl: Refactoring: Remove ResetViewportSize

This commit is contained in:
Hajime Hoshi 2018-11-02 03:24:35 +09:00
parent 09fe1886d7
commit 6dceeb343c
2 changed files with 10 additions and 14 deletions

View File

@ -146,13 +146,6 @@ func (q *commandQueue) Flush() {
return return
} }
// glViewport must be called at least at every frame on iOS.
// This is introduced at https://github.com/hajimehoshi/ebiten/commit/e9de66aca2007a679de4ba11ea14ef061dca2f6e.
// At that time viewport sizes were always same so it was needed to force to call
// glViewport, but now viewport sizes can change and apps can work without this. This is
// needed only when the screen framebuffer size and the first framebuffer size are same,
// probably.
opengl.GetContext().ResetViewportSize()
es := q.indices es := q.indices
vs := q.vertices vs := q.vertices
if recordLog() { if recordLog() {

View File

@ -100,20 +100,23 @@ func (c *Context) SetViewport(f Framebuffer, width, height int) {
c.bindFramebuffer(f) c.bindFramebuffer(f)
if c.lastViewportWidth != width || c.lastViewportHeight != height { if c.lastViewportWidth != width || c.lastViewportHeight != height {
c.setViewportImpl(width, height) c.setViewportImpl(width, height)
// glViewport must be called at least at every frame on iOS.
// As the screen framebuffer is the last render target, next SetViewport should be
// the first call at a frame.
if f == c.screenFramebuffer {
c.lastViewportWidth = 0
c.lastViewportHeight = 0
} else {
c.lastViewportWidth = width c.lastViewportWidth = width
c.lastViewportHeight = height c.lastViewportHeight = height
} }
}
} }
func (c *Context) ScreenFramebuffer() Framebuffer { func (c *Context) ScreenFramebuffer() Framebuffer {
return c.screenFramebuffer return c.screenFramebuffer
} }
func (c *Context) ResetViewportSize() {
c.lastViewportWidth = 0
c.lastViewportHeight = 0
}
func (c *Context) MaxTextureSize() int { func (c *Context) MaxTextureSize() int {
if c.maxTextureSize == 0 { if c.maxTextureSize == 0 {
c.maxTextureSize = c.maxTextureSizeImpl() c.maxTextureSize = c.maxTextureSizeImpl()