From ca3322edbc7fda13a4453262bcb3eba49e7b3853 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 4 Jun 2016 03:50:28 +0900 Subject: [PATCH] opengl: Refactoring: Rename functions --- internal/graphics/opengl/context_desktop.go | 4 ++-- internal/graphics/opengl/context_js.go | 4 ++-- internal/graphics/opengl/context_mobile.go | 4 ++-- internal/graphics/opengl/locationcache.go | 18 ++++-------------- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/internal/graphics/opengl/context_desktop.go b/internal/graphics/opengl/context_desktop.go index 6749092ab..fa3707e79 100644 --- a/internal/graphics/opengl/context_desktop.go +++ b/internal/graphics/opengl/context_desktop.go @@ -332,7 +332,7 @@ func (c *Context) UseProgram(p Program) { }) } -func (c *Context) getUniformLocation(p Program, location string) uniformLocation { +func (c *Context) getUniformLocationImpl(p Program, location string) uniformLocation { uniform := uniformLocation(gl.GetUniformLocation(uint32(p), gl.Str(location+"\x00"))) if uniform == -1 { panic("opengl: invalid uniform location: " + location) @@ -363,7 +363,7 @@ func (c *Context) UniformFloats(p Program, location string, v []float32) { }) } -func (c *Context) getAttribLocation(p Program, location string) attribLocation { +func (c *Context) getAttribLocationImpl(p Program, location string) attribLocation { attrib := attribLocation(gl.GetAttribLocation(uint32(p), gl.Str(location+"\x00"))) if attrib == -1 { panic("opengl: invalid attrib location: " + location) diff --git a/internal/graphics/opengl/context_js.go b/internal/graphics/opengl/context_js.go index 525a4b7c3..55b3624f6 100644 --- a/internal/graphics/opengl/context_js.go +++ b/internal/graphics/opengl/context_js.go @@ -287,7 +287,7 @@ func (c *Context) UseProgram(p Program) { gl.UseProgram(p.Object) } -func (c *Context) getUniformLocation(p Program, location string) uniformLocation { +func (c *Context) getUniformLocationImpl(p Program, location string) uniformLocation { gl := c.gl return uniformLocation{gl.GetUniformLocation(p.Object, location)} } @@ -311,7 +311,7 @@ func (c *Context) UniformFloats(p Program, location string, v []float32) { } } -func (c *Context) getAttribLocation(p Program, location string) attribLocation { +func (c *Context) getAttribLocationImpl(p Program, location string) attribLocation { gl := c.gl return attribLocation(gl.GetAttribLocation(p.Object, location)) } diff --git a/internal/graphics/opengl/context_mobile.go b/internal/graphics/opengl/context_mobile.go index f7e35e848..25252f7e6 100644 --- a/internal/graphics/opengl/context_mobile.go +++ b/internal/graphics/opengl/context_mobile.go @@ -258,7 +258,7 @@ func (c *Context) UseProgram(p Program) { gl.UseProgram(mgl.Program(p)) } -func (c *Context) getUniformLocation(p Program, location string) uniformLocation { +func (c *Context) getUniformLocationImpl(p Program, location string) uniformLocation { gl := c.gl u := uniformLocation(gl.GetUniformLocation(mgl.Program(p), location)) if u.Value == -1 { @@ -285,7 +285,7 @@ func (c *Context) UniformFloats(p Program, location string, v []float32) { } } -func (c *Context) getAttribLocation(p Program, location string) attribLocation { +func (c *Context) getAttribLocationImpl(p Program, location string) attribLocation { gl := c.gl a := attribLocation(gl.GetAttribLocation(mgl.Program(p), location)) if a.Value == ^uint(0) { diff --git a/internal/graphics/opengl/locationcache.go b/internal/graphics/opengl/locationcache.go index 62ec1ba45..25a81546f 100644 --- a/internal/graphics/opengl/locationcache.go +++ b/internal/graphics/opengl/locationcache.go @@ -28,37 +28,27 @@ func newLocationCache() *locationCache { } } -type uniformLocationGetter interface { - getUniformLocation(p Program, location string) uniformLocation -} - -// TODO: Rename these functions not to be confusing - -func (c *locationCache) GetUniformLocation(g uniformLocationGetter, p Program, location string) uniformLocation { +func (c *locationCache) GetUniformLocation(context *Context, p Program, location string) uniformLocation { id := p.id() if _, ok := c.uniformLocationCache[id]; !ok { c.uniformLocationCache[id] = map[string]uniformLocation{} } l, ok := c.uniformLocationCache[id][location] if !ok { - l = g.getUniformLocation(p, location) + l = context.getUniformLocationImpl(p, location) c.uniformLocationCache[id][location] = l } return l } -type attribLocationGetter interface { - getAttribLocation(p Program, location string) attribLocation -} - -func (c *locationCache) GetAttribLocation(g attribLocationGetter, p Program, location string) attribLocation { +func (c *locationCache) GetAttribLocation(context *Context, p Program, location string) attribLocation { id := p.id() if _, ok := c.attribLocationCache[id]; !ok { c.attribLocationCache[id] = map[string]attribLocation{} } l, ok := c.attribLocationCache[id][location] if !ok { - l = g.getAttribLocation(p, location) + l = context.getAttribLocationImpl(p, location) c.attribLocationCache[id][location] = l } return l