From ccf0acf7ca9fb4fbd118c6bd80ccdd87fcab2f41 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 27 Feb 2016 03:05:12 +0900 Subject: [PATCH] opengl: Reduce global variables --- internal/graphics/opengl/context_js.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/internal/graphics/opengl/context_js.go b/internal/graphics/opengl/context_js.go index 3c8d2a0a3..b3d7b1ccb 100644 --- a/internal/graphics/opengl/context_js.go +++ b/internal/graphics/opengl/context_js.go @@ -66,6 +66,7 @@ type context struct { gl *webgl.Context lastFramebuffer Framebuffer locationCache *locationCache + lastProgramID programID } func NewContext() *Context { @@ -206,8 +207,6 @@ func (c *Context) NewFramebuffer(t Texture) (Framebuffer, error) { return Framebuffer{f}, nil } -var lastBindedFramebuffer *js.Object - func (c *Context) SetViewport(f Framebuffer, width, height int) error { // TODO: Not sure if Flush is needed here. if f.Object == nil { @@ -266,16 +265,14 @@ func (c *Context) GlslHighpSupported() bool { return gl.Call("getShaderPrecisionFormat", gl.FRAGMENT_SHADER, gl.HIGH_FLOAT).Get("precision").Int() != 0 } -var lastProgramID programID = 0 - func (c *Context) NewProgram(shaders []Shader) (Program, error) { gl := c.gl p := gl.CreateProgram() if p == nil { return Program{nil}, errors.New("opengl: glCreateProgram failed") } - p.Set("__ebiten_programId", lastProgramID) - lastProgramID++ + p.Set("__ebiten_programId", c.lastProgramID) + c.lastProgramID++ for _, shader := range shaders { gl.AttachShader(p, shader.Object)