opengl: Refactoring: Rename functions

This commit is contained in:
Hajime Hoshi 2016-06-04 03:50:28 +09:00
parent da1354ec51
commit ca3322edbc
4 changed files with 10 additions and 20 deletions

View File

@ -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)

View File

@ -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))
}

View File

@ -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) {

View File

@ -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