I=(S=Uno.Graphics.Texture2D = function(){
}).prototype;

I.GLHandle = function()
{
    return this.tex;
};

I.Width = function()
{
    return this.width;
};

I.Height = function()
{
    return this.height;
};

S.$0 = function(width, height, format, $this) {
    if (!$this) $this = new Uno.Graphics.Texture2D;
    $this.width = width;
    $this.height = height;
    $this.mips = 1;
    $this.tex = gl.createTexture();
    gl.bindTexture(3553, $this.tex);
    gl.texParameteri(3553, 10240, 9729);
    gl.texParameteri(3553, 10241, 9729);
    gl.texParameteri(3553, 10242, 33071);
    gl.texParameteri(3553, 10243, 33071);

    switch (format)
    {
        case 0:
        {
            gl.texImage2D(3553, 0, 6409, width, height, 0, 6409, 5121, null);
            break;
        }
        case 1:
        {
            gl.texImage2D(3553, 0, 6410, width, height, 0, 6410, 5121, null);
            break;
        }
        case 2:
        {
            gl.texImage2D(3553, 0, 6408, width, height, 0, 6408, 5121, null);
            break;
        }
        case 3:
        {
            gl.texImage2D(3553, 0, 6408, width, height, 0, 6408, 32819, null);
            break;
        }
        case 4:
        {
            gl.texImage2D(3553, 0, 6408, width, height, 0, 6408, 32820, null);
            break;
        }
        case 5:
        {
            gl.texImage2D(3553, 0, 6407, width, height, 0, 6407, 33635, null);
            break;
        }
        default:
        {
            throw Uno.Exception.$0("Unsupported texture format");
        }
    }

    gl.bindTexture(3553, null);
    return $this;
};

S.$1 = function(filename, $this) {
    if (!$this) $this = new Uno.Graphics.Texture2D;
    $this.tex = gl.createTexture();
    gl.bindTexture(3553, $this.tex);
    uglLoadTexture(3553, $this.tex, filename, ref(function(){return $this.width}, function($){$this.width=$}, this), ref(function(){return $this.height}, function($){$this.height=$}, this), ref(function(){return $this.mips}, function($){$this.mips=$}, this));

    if ($this.mips > 1)
    {
        gl.texParameteri(3553, 10240, 9729);
        gl.texParameteri(3553, 10241, 9987);
    }
    else
    {
        gl.texParameteri(3553, 10240, 9729);
        gl.texParameteri(3553, 10241, 9729);
        gl.texParameteri(3553, 10242, 33071);
        gl.texParameteri(3553, 10243, 33071);
    }

    gl.bindTexture(3553, null);
    return $this;
};
