From f80850ef143d57cd5187e711b683bd70472b5e30 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 3 Jan 2015 16:21:09 +0900 Subject: [PATCH] Reduce calling gl.Flush --- internal/opengl/context_js.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/opengl/context_js.go b/internal/opengl/context_js.go index 56dd131b1..546d4cf1b 100644 --- a/internal/opengl/context_js.go +++ b/internal/opengl/context_js.go @@ -126,9 +126,14 @@ func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) { return Framebuffer(f), nil } +var lastFramebuffer Framebuffer + func (c *Context) SetViewport(f Framebuffer, width, height int) error { gl := c.gl - gl.Flush() + if lastFramebuffer != f { + gl.Flush() + lastFramebuffer = f + } if f != nil { gl.BindFramebuffer(gl.FRAMEBUFFER, f) } else {