TextureValidIndex returns the index of the given texture value at our index in list of vals, starting at given index, skipping over any inactive textures which do not show up when accessed in the shader. You must use this value when passing a texture index to the shader! returns -1 if idx is not val
(stIndex, idx int)
| 183 | // You must use this value when passing a texture index to the shader! |
| 184 | // returns -1 if idx is not valid |
| 185 | func (vr *Var) TextureValidIndex(stIndex, idx int) int { |
| 186 | vals := vr.Values.ActiveValues() |
| 187 | vidx := 0 |
| 188 | mx := min(stIndex+MaxTexturesPerSet, len(vals)) |
| 189 | for i := stIndex; i < mx; i++ { |
| 190 | vl := vals[i] |
| 191 | if i == idx { |
| 192 | return vidx |
| 193 | } |
| 194 | if vl.Texture == nil || !vl.Texture.IsActive() { |
| 195 | if i == idx { |
| 196 | return -1 |
| 197 | } |
| 198 | continue |
| 199 | } |
| 200 | vidx++ |
| 201 | } |
| 202 | return -1 |
| 203 | } |
| 204 | |
| 205 | ////////////////////////////////////////////////////////////////// |
| 206 | // VarList |
no test coverage detected