I have very strange problem with setting texture from file. If I use
Uint8Array
instead (commented in code below) everything is ok and works. What important did I missed? Program always reaches "onload" so file is ok and it loads! Using more "untyped" constructions in various suitable places does not helps me.
public
function
addTexture(): Dynamic
{
var
image: Image = untyped __js__(
"new Image()"
);
image.src =
"textures/tex0.png"
;
image.onload =
function
(e: Event)
{
texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.CLAMP);
gl.texParameteri(gl.TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.CLAMP);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1024, 512, 0, gl.RGBA, gl.UNSIGNED_BYTE, image);
/*
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 2, 2, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([
255, 110, 0, 255,
255, 110, 250, 255,
255, 0, 0, 255,
55, 110, 0, 255
]));
*/
}