The Textured Box demo at http://www.khronos.org/webgl/wiki/Demo_Repository contains the following code fragments:
function loadImageTexture(ctx, url)
{
var texture = ctx.createTexture();
texture.image = new Image();
texture.image.onload = function()
{ doLoadImageTexture(ctx, texture.image, texture) }
texture.image.src = url;
return texture;
}
function doLoadImageTexture(ctx, image, texture)
{
ctx.bindTexture(ctx.TEXTURE_2D, texture);
ctx.texImage2D(ctx.TEXTURE_2D, 0, ctx.RGBA, ctx.RGBA, ctx.UNSIGNED_BYTE, image);
...
}
...
var spiritTexture = loadImageTexture(gl, "resources/spirit.jpg");
...
How do you free selected / loaded texture to avoid memory leak (graphics)?
Will the following code contain both the loaded / selected texture and image?
spiritTexture = null;
Thanks in advance for your help.
NOTE. Cross the post http://www.khronos.org/message_boards/viewtopic.php?f=43&t=3367 December 23, 2010, but there is no answer yet.
source
share