From 5c755f2f310bbce0f3faff88e2ad42f7dac50616 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 2 Jan 2015 23:52:40 +0900 Subject: [PATCH] Fix BindFramebuffer to pass JS null object explicitly --- internal/opengl/context_js.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/opengl/context_js.go b/internal/opengl/context_js.go index 0082801fa..9a71e33a5 100644 --- a/internal/opengl/context_js.go +++ b/internal/opengl/context_js.go @@ -32,6 +32,9 @@ type context struct { gl *webgl.Context } +// TODO: Is there any better way to get null value? +var nullVal = js.Global.Call("eval", "null") + func NewContext(gl *webgl.Context) *Context { c := &Context{ Nearest: FilterType(gl.NEAREST), @@ -123,7 +126,11 @@ func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) { func (c *Context) SetViewport(f Framebuffer, width, height int) error { gl := c.gl gl.Flush() - gl.BindFramebuffer(gl.FRAMEBUFFER, f) + if f != nil { + gl.BindFramebuffer(gl.FRAMEBUFFER, f) + } else { + gl.BindFramebuffer(gl.FRAMEBUFFER, nullVal) + } err := gl.CheckFramebufferStatus(gl.FRAMEBUFFER) if err != gl.FRAMEBUFFER_COMPLETE { if gl.GetError() != 0 {