From d8e7ec52747062cd81243a378502a02a1ae6ed16 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 9 Jul 2016 23:14:24 +0900 Subject: [PATCH] opengl: Initialize lastTexture --- internal/graphics/opengl/context_desktop.go | 6 +++++- internal/graphics/opengl/context_js.go | 6 +++++- internal/graphics/opengl/context_mobile.go | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/internal/graphics/opengl/context_desktop.go b/internal/graphics/opengl/context_desktop.go index 336ffe5e7..692be6741 100644 --- a/internal/graphics/opengl/context_desktop.go +++ b/internal/graphics/opengl/context_desktop.go @@ -37,7 +37,10 @@ type attribLocation int32 type programID uint32 -const invalidFramebuffer = (1 << 32) - 1 +const ( + invalidTexture = 0 + invalidFramebuffer = (1 << 32) - 1 +) func (p Program) id() programID { return programID(p) @@ -106,6 +109,7 @@ func (c *Context) Reset() error { return nil } c.locationCache = newLocationCache() + c.lastTexture = invalidTexture c.lastFramebuffer = invalidFramebuffer c.lastViewportWidth = 0 c.lastViewportHeight = 0 diff --git a/internal/graphics/opengl/context_js.go b/internal/graphics/opengl/context_js.go index bdac953de..4db846aa2 100644 --- a/internal/graphics/opengl/context_js.go +++ b/internal/graphics/opengl/context_js.go @@ -52,7 +52,10 @@ type attribLocation int type programID int -var invalidFramebuffer = Framebuffer{nil} +var ( + invalidTexture = Texture{} + invalidFramebuffer = Framebuffer{} +) func (p Program) id() programID { return programID(p.Get("__ebiten_programId").Int()) @@ -115,6 +118,7 @@ func NewContext() (*Context, error) { func (c *Context) Reset() error { c.locationCache = newLocationCache() + c.lastTexture = invalidTexture c.lastFramebuffer = invalidFramebuffer c.lastViewportWidth = 0 c.lastViewportHeight = 0 diff --git a/internal/graphics/opengl/context_mobile.go b/internal/graphics/opengl/context_mobile.go index da3e4d0c7..c0a905836 100644 --- a/internal/graphics/opengl/context_mobile.go +++ b/internal/graphics/opengl/context_mobile.go @@ -34,7 +34,10 @@ type attribLocation mgl.Attrib type programID uint32 -var invalidFramebuffer = Framebuffer(mgl.Framebuffer{(1 << 32) - 1}) +var ( + invalidTexture = Texture(mgl.Texture{}) + invalidFramebuffer = Framebuffer(mgl.Framebuffer{(1 << 32) - 1}) +) func (p Program) id() programID { return programID(p.Value) @@ -93,6 +96,7 @@ loop: func (c *Context) Reset() error { c.locationCache = newLocationCache() + c.lastTexture = invalidTexture c.lastFramebuffer = invalidFramebuffer c.lastViewportWidth = 0 c.lastViewportHeight = 0