Description
I think there may be something off with the implementation of the getTexture() function. The function looks like this:
p5.RendererGL.prototype.getTexture = function(img) {
const textures = this.textures;
for (const texture of textures) {
if (texture.src === img) return texture;
}
const tex = new p5.Texture(this, img);
textures.push(tex);
return tex;
};
However, nowhere in the renderer or anywhere else in the codebase are we ever pushing anything into this.textures
, so the loop will never do anything, since we're not storing textures anywhere.
Moreover, I'm suspicious of that if statement inside of the loop. Even if we were caching our textures, it seems like that check is testing to see if the Image objects are the same, which I think may be likely to be false 100% of the time, and even if they were the same, wouldn't this be a very expensive operation?
Maybe we can think of some better ways to cache and check for pre-existing textures here, or maybe we can just remove some of the other lines in there so that the function just creates and returns a new texture, until we figure out a better solution.
@stalgiag Any ideas?
Metadata
Metadata
Assignees
Type
Projects
Status