Im working on webgl app. I have starsList
array and for some reason, when I run this function:
function initTextures() {
for (i = 0; i < starsList.length; i++) {
starsList[i].texture = gl.createTexture();
starsList[i].texture.image = new Image();
starsList[i].texture.image.onload = function () {
handleLoadedTexture(starsList[i].texture)
}
starsList[i].texture.image.src = starsList[i].name + ".gif";
}
}
I got this error:
TypeError: starsList[i] is undefined
handleLoadedTexture(starsList[i].texture)
although starsList[i].texture
defined at the first line in the loop.
any ideas why?