mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
opengl: Unexport Attrib/UniformLocation
This commit is contained in:
parent
ccf0acf7ca
commit
997539b243
@ -37,8 +37,8 @@ func (p Program) Equals(other Program) bool {
|
||||
return p == other
|
||||
}
|
||||
|
||||
type UniformLocation int32
|
||||
type AttribLocation int32
|
||||
type uniformLocation int32
|
||||
type attribLocation int32
|
||||
|
||||
type programID uint32
|
||||
|
||||
@ -313,8 +313,8 @@ func (c *Context) UseProgram(p Program) {
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Context) getUniformLocation(p Program, location string) UniformLocation {
|
||||
uniform := UniformLocation(gl.GetUniformLocation(uint32(p), gl.Str(location+"\x00")))
|
||||
func (c *Context) getUniformLocation(p Program, location string) uniformLocation {
|
||||
uniform := uniformLocation(gl.GetUniformLocation(uint32(p), gl.Str(location+"\x00")))
|
||||
if uniform == -1 {
|
||||
panic("opengl: invalid uniform location: " + location)
|
||||
}
|
||||
@ -342,8 +342,8 @@ func (c *Context) UniformFloats(p Program, location string, v []float32) {
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Context) getAttribLocation(p Program, location string) AttribLocation {
|
||||
attrib := AttribLocation(gl.GetAttribLocation(uint32(p), gl.Str(location+"\x00")))
|
||||
func (c *Context) getAttribLocation(p Program, location string) attribLocation {
|
||||
attrib := attribLocation(gl.GetAttribLocation(uint32(p), gl.Str(location+"\x00")))
|
||||
if attrib == -1 {
|
||||
panic("invalid attrib location: " + location)
|
||||
}
|
||||
|
@ -50,11 +50,11 @@ func (p Program) Equals(other Program) bool {
|
||||
return p.Object == other.Object
|
||||
}
|
||||
|
||||
type UniformLocation struct {
|
||||
type uniformLocation struct {
|
||||
*js.Object
|
||||
}
|
||||
|
||||
type AttribLocation int
|
||||
type attribLocation int
|
||||
|
||||
type programID int
|
||||
|
||||
@ -289,9 +289,9 @@ func (c *Context) UseProgram(p Program) {
|
||||
gl.UseProgram(p.Object)
|
||||
}
|
||||
|
||||
func (c *Context) getUniformLocation(p Program, location string) UniformLocation {
|
||||
func (c *Context) getUniformLocation(p Program, location string) uniformLocation {
|
||||
gl := c.gl
|
||||
return UniformLocation{gl.GetUniformLocation(p.Object, location)}
|
||||
return uniformLocation{gl.GetUniformLocation(p.Object, location)}
|
||||
}
|
||||
|
||||
func (c *Context) UniformInt(p Program, location string, v int) {
|
||||
@ -313,9 +313,9 @@ func (c *Context) UniformFloats(p Program, location string, v []float32) {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Context) getAttribLocation(p Program, location string) AttribLocation {
|
||||
func (c *Context) getAttribLocation(p Program, location string) attribLocation {
|
||||
gl := c.gl
|
||||
return AttribLocation(gl.GetAttribLocation(p.Object, location))
|
||||
return attribLocation(gl.GetAttribLocation(p.Object, location))
|
||||
}
|
||||
|
||||
func (c *Context) VertexAttribPointer(p Program, location string, normalize bool, stride int, size int, v int) {
|
||||
|
@ -38,8 +38,8 @@ func (p Program) Equals(other Program) bool {
|
||||
return p == other
|
||||
}
|
||||
|
||||
type UniformLocation mgl.Uniform
|
||||
type AttribLocation mgl.Attrib
|
||||
type uniformLocation mgl.Uniform
|
||||
type attribLocation mgl.Attrib
|
||||
|
||||
type programID uint32
|
||||
|
||||
@ -252,8 +252,8 @@ func (c *Context) UseProgram(p Program) {
|
||||
gl.UseProgram(mgl.Program(p))
|
||||
}
|
||||
|
||||
func (c *Context) getUniformLocation(p Program, location string) UniformLocation {
|
||||
u := UniformLocation(gl.GetUniformLocation(mgl.Program(p), location))
|
||||
func (c *Context) getUniformLocation(p Program, location string) uniformLocation {
|
||||
u := uniformLocation(gl.GetUniformLocation(mgl.Program(p), location))
|
||||
if u.Value == -1 {
|
||||
panic("invalid uniform location: " + location)
|
||||
}
|
||||
@ -276,8 +276,8 @@ func (c *Context) UniformFloats(p Program, location string, v []float32) {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Context) getAttribLocation(p Program, location string) AttribLocation {
|
||||
a := AttribLocation(gl.GetAttribLocation(mgl.Program(p), location))
|
||||
func (c *Context) getAttribLocation(p Program, location string) attribLocation {
|
||||
a := attribLocation(gl.GetAttribLocation(mgl.Program(p), location))
|
||||
if a.Value == ^uint(0) {
|
||||
panic("invalid attrib location: " + location)
|
||||
}
|
||||
|
@ -17,27 +17,27 @@ package opengl
|
||||
// Since js.Object (Program) can't be keys of a map, use integers (programID) instead.
|
||||
|
||||
type locationCache struct {
|
||||
uniformLocationCache map[programID]map[string]UniformLocation
|
||||
attribLocationCache map[programID]map[string]AttribLocation
|
||||
uniformLocationCache map[programID]map[string]uniformLocation
|
||||
attribLocationCache map[programID]map[string]attribLocation
|
||||
}
|
||||
|
||||
func newLocationCache() *locationCache {
|
||||
return &locationCache{
|
||||
uniformLocationCache: map[programID]map[string]UniformLocation{},
|
||||
attribLocationCache: map[programID]map[string]AttribLocation{},
|
||||
uniformLocationCache: map[programID]map[string]uniformLocation{},
|
||||
attribLocationCache: map[programID]map[string]attribLocation{},
|
||||
}
|
||||
}
|
||||
|
||||
type uniformLocationGetter interface {
|
||||
getUniformLocation(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 {
|
||||
func (c *locationCache) GetUniformLocation(g uniformLocationGetter, p Program, location string) uniformLocation {
|
||||
id := p.id()
|
||||
if _, ok := c.uniformLocationCache[id]; !ok {
|
||||
c.uniformLocationCache[id] = map[string]UniformLocation{}
|
||||
c.uniformLocationCache[id] = map[string]uniformLocation{}
|
||||
}
|
||||
l, ok := c.uniformLocationCache[id][location]
|
||||
if !ok {
|
||||
@ -48,13 +48,13 @@ func (c *locationCache) GetUniformLocation(g uniformLocationGetter, p Program, l
|
||||
}
|
||||
|
||||
type attribLocationGetter interface {
|
||||
getAttribLocation(p Program, location string) AttribLocation
|
||||
getAttribLocation(p Program, location string) attribLocation
|
||||
}
|
||||
|
||||
func (c *locationCache) GetAttribLocation(g attribLocationGetter, p Program, location string) AttribLocation {
|
||||
func (c *locationCache) GetAttribLocation(g attribLocationGetter, p Program, location string) attribLocation {
|
||||
id := p.id()
|
||||
if _, ok := c.attribLocationCache[id]; !ok {
|
||||
c.attribLocationCache[id] = map[string]AttribLocation{}
|
||||
c.attribLocationCache[id] = map[string]attribLocation{}
|
||||
}
|
||||
l, ok := c.attribLocationCache[id][location]
|
||||
if !ok {
|
||||
|
Loading…
Reference in New Issue
Block a user