mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
opengl: Refactoring: Rename functions
This commit is contained in:
parent
da1354ec51
commit
ca3322edbc
@ -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")))
|
uniform := uniformLocation(gl.GetUniformLocation(uint32(p), gl.Str(location+"\x00")))
|
||||||
if uniform == -1 {
|
if uniform == -1 {
|
||||||
panic("opengl: invalid uniform location: " + location)
|
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")))
|
attrib := attribLocation(gl.GetAttribLocation(uint32(p), gl.Str(location+"\x00")))
|
||||||
if attrib == -1 {
|
if attrib == -1 {
|
||||||
panic("opengl: invalid attrib location: " + location)
|
panic("opengl: invalid attrib location: " + location)
|
||||||
|
@ -287,7 +287,7 @@ func (c *Context) UseProgram(p Program) {
|
|||||||
gl.UseProgram(p.Object)
|
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
|
gl := c.gl
|
||||||
return uniformLocation{gl.GetUniformLocation(p.Object, location)}
|
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
|
gl := c.gl
|
||||||
return attribLocation(gl.GetAttribLocation(p.Object, location))
|
return attribLocation(gl.GetAttribLocation(p.Object, location))
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ func (c *Context) UseProgram(p Program) {
|
|||||||
gl.UseProgram(mgl.Program(p))
|
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
|
gl := c.gl
|
||||||
u := uniformLocation(gl.GetUniformLocation(mgl.Program(p), location))
|
u := uniformLocation(gl.GetUniformLocation(mgl.Program(p), location))
|
||||||
if u.Value == -1 {
|
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
|
gl := c.gl
|
||||||
a := attribLocation(gl.GetAttribLocation(mgl.Program(p), location))
|
a := attribLocation(gl.GetAttribLocation(mgl.Program(p), location))
|
||||||
if a.Value == ^uint(0) {
|
if a.Value == ^uint(0) {
|
||||||
|
@ -28,37 +28,27 @@ func newLocationCache() *locationCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type uniformLocationGetter interface {
|
func (c *locationCache) GetUniformLocation(context *Context, p Program, location string) uniformLocation {
|
||||||
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 {
|
|
||||||
id := p.id()
|
id := p.id()
|
||||||
if _, ok := c.uniformLocationCache[id]; !ok {
|
if _, ok := c.uniformLocationCache[id]; !ok {
|
||||||
c.uniformLocationCache[id] = map[string]uniformLocation{}
|
c.uniformLocationCache[id] = map[string]uniformLocation{}
|
||||||
}
|
}
|
||||||
l, ok := c.uniformLocationCache[id][location]
|
l, ok := c.uniformLocationCache[id][location]
|
||||||
if !ok {
|
if !ok {
|
||||||
l = g.getUniformLocation(p, location)
|
l = context.getUniformLocationImpl(p, location)
|
||||||
c.uniformLocationCache[id][location] = l
|
c.uniformLocationCache[id][location] = l
|
||||||
}
|
}
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
|
||||||
type attribLocationGetter interface {
|
func (c *locationCache) GetAttribLocation(context *Context, p Program, location string) attribLocation {
|
||||||
getAttribLocation(p Program, location string) attribLocation
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *locationCache) GetAttribLocation(g attribLocationGetter, p Program, location string) attribLocation {
|
|
||||||
id := p.id()
|
id := p.id()
|
||||||
if _, ok := c.attribLocationCache[id]; !ok {
|
if _, ok := c.attribLocationCache[id]; !ok {
|
||||||
c.attribLocationCache[id] = map[string]attribLocation{}
|
c.attribLocationCache[id] = map[string]attribLocation{}
|
||||||
}
|
}
|
||||||
l, ok := c.attribLocationCache[id][location]
|
l, ok := c.attribLocationCache[id][location]
|
||||||
if !ok {
|
if !ok {
|
||||||
l = g.getAttribLocation(p, location)
|
l = context.getAttribLocationImpl(p, location)
|
||||||
c.attribLocationCache[id][location] = l
|
c.attribLocationCache[id][location] = l
|
||||||
}
|
}
|
||||||
return l
|
return l
|
||||||
|
Loading…
Reference in New Issue
Block a user