|
@@ -8,7 +8,7 @@ import (
|
|
|
"fmt"
|
|
"fmt"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-type Uniform2 struct {
|
|
|
|
|
|
|
+type Uniform struct {
|
|
|
name string // base name
|
|
name string // base name
|
|
|
nameIdx string // cached indexed name
|
|
nameIdx string // cached indexed name
|
|
|
handle uint32 // program handle
|
|
handle uint32 // program handle
|
|
@@ -17,7 +17,7 @@ type Uniform2 struct {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Init initializes this uniform location cache and sets its name
|
|
// Init initializes this uniform location cache and sets its name
|
|
|
-func (u *Uniform2) Init(name string) {
|
|
|
|
|
|
|
+func (u *Uniform) Init(name string) {
|
|
|
|
|
|
|
|
u.name = name
|
|
u.name = name
|
|
|
u.handle = 0 // invalid program handle
|
|
u.handle = 0 // invalid program handle
|
|
@@ -28,13 +28,12 @@ func (u *Uniform2) Init(name string) {
|
|
|
// Location returns the location of this uniform for
|
|
// Location returns the location of this uniform for
|
|
|
// the current shader program
|
|
// the current shader program
|
|
|
// The returned location can be -1 if not found
|
|
// The returned location can be -1 if not found
|
|
|
-func (u *Uniform2) Location(gs *GLS) int32 {
|
|
|
|
|
|
|
+func (u *Uniform) Location(gs *GLS) int32 {
|
|
|
|
|
|
|
|
handle := gs.prog.Handle()
|
|
handle := gs.prog.Handle()
|
|
|
if handle != u.handle {
|
|
if handle != u.handle {
|
|
|
u.location = gs.prog.GetUniformLocation(u.name)
|
|
u.location = gs.prog.GetUniformLocation(u.name)
|
|
|
u.handle = handle
|
|
u.handle = handle
|
|
|
- //log.Error("Uniform:%s location:%v", u.name, u.location)
|
|
|
|
|
}
|
|
}
|
|
|
return u.location
|
|
return u.location
|
|
|
}
|
|
}
|
|
@@ -42,19 +41,17 @@ func (u *Uniform2) Location(gs *GLS) int32 {
|
|
|
// LocationIdx returns the location of this indexed uniform for
|
|
// LocationIdx returns the location of this indexed uniform for
|
|
|
// the current shader program
|
|
// the current shader program
|
|
|
// The returned location can be -1 if not found
|
|
// The returned location can be -1 if not found
|
|
|
-func (u *Uniform2) LocationIdx(gs *GLS, idx int32) int32 {
|
|
|
|
|
|
|
+func (u *Uniform) LocationIdx(gs *GLS, idx int32) int32 {
|
|
|
|
|
|
|
|
if idx != u.lastIndex {
|
|
if idx != u.lastIndex {
|
|
|
u.nameIdx = fmt.Sprintf("%s[%d]", u.name, idx)
|
|
u.nameIdx = fmt.Sprintf("%s[%d]", u.name, idx)
|
|
|
u.lastIndex = idx
|
|
u.lastIndex = idx
|
|
|
u.handle = 0
|
|
u.handle = 0
|
|
|
- //log.Error("Uniform:%s rebuild nameIdx", u.nameIdx)
|
|
|
|
|
}
|
|
}
|
|
|
handle := gs.prog.Handle()
|
|
handle := gs.prog.Handle()
|
|
|
if handle != u.handle {
|
|
if handle != u.handle {
|
|
|
u.location = gs.prog.GetUniformLocation(u.nameIdx)
|
|
u.location = gs.prog.GetUniformLocation(u.nameIdx)
|
|
|
u.handle = handle
|
|
u.handle = handle
|
|
|
- //log.Error("Uniform:%s location:%v", u.nameIdx, u.location)
|
|
|
|
|
}
|
|
}
|
|
|
return u.location
|
|
return u.location
|
|
|
}
|
|
}
|