MCPcopy Create free account
hub / github.com/cogentcore/core / TextureValidIndex

Method TextureValidIndex

vgpu/var.go:185–203  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

183// You must use this value when passing a texture index to the shader!
184// returns -1 if idx is not valid
185func (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

Callers 1

Calls 2

ActiveValuesMethod · 0.80
IsActiveMethod · 0.80

Tested by

no test coverage detected