mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
opengl: Reduce calls of glSetViewport
This commit is contained in:
parent
4c2650c721
commit
e5965d7771
@ -39,9 +39,11 @@ type Context struct {
|
|||||||
context
|
context
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) bindFramebuffer(f Framebuffer) {
|
func (c *Context) bindFramebuffer(f Framebuffer) bool {
|
||||||
if c.lastFramebuffer != f {
|
if c.lastFramebuffer != f {
|
||||||
c.bindFramebufferImpl(f)
|
c.bindFramebufferImpl(f)
|
||||||
c.lastFramebuffer = f
|
c.lastFramebuffer = f
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
@ -228,8 +228,9 @@ 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 {
|
||||||
c.bindFramebuffer(f)
|
if c.bindFramebuffer(f) {
|
||||||
gl.Viewport(0, 0, int32(width), int32(height))
|
gl.Viewport(0, 0, int32(width), int32(height))
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -205,9 +205,10 @@ 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 {
|
||||||
c.bindFramebuffer(f)
|
if c.bindFramebuffer(f) {
|
||||||
gl := c.gl
|
gl := c.gl
|
||||||
gl.Viewport(0, 0, width, height)
|
gl.Viewport(0, 0, width, height)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,9 +182,10 @@ 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 {
|
||||||
gl := c.gl
|
if c.bindFramebuffer(f) {
|
||||||
c.bindFramebuffer(f)
|
gl := c.gl
|
||||||
gl.Viewport(0, 0, width, height)
|
gl.Viewport(0, 0, width, height)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user