<html>
<head>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"></script>
<script src="resources/webgl-test-utils.js"></script>
<script>
var wtu = WebGLTestUtils;
var gl = null;
var textureLoc = null;
var successfullyParsed = false;

function init()
{
    if (window.initNonKhronosFramework) {
        window.initNonKhronosFramework(true);
    }

    description('Tests there is no garbage in transparent regions of images uploaded as textures');

    wtu = WebGLTestUtils;
    var canvas = document.getElementById("example");
    gl = wtu.create3DContext(canvas);
    var program = wtu.setupTexturedQuad(gl);
    gl.clearColor(0.5,0.5,0.5,1);
    gl.clearDepth(1);

    textureLoc = gl.getUniformLocation(program, "tex");

    // The input texture has 8 characters; take the leftmost one
    var coeff = 1.0 / 8.0;
    var texCoords = new Float32Array([
        coeff, 1.0,
        0.0, 1.0,
        0.0, 0.0,
        coeff, 1.0,
        0.0, 0.0,
        coeff, 0.0]);

    var vbo = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
    gl.bufferData(gl.ARRAY_BUFFER, texCoords, gl.STATIC_DRAW);
    gl.enableVertexAttribArray(1);
    gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0);

    texture = wtu.loadTexture(gl, "resources/bug-32888-texture.png", runTest);
}

// These two declarations need to be global for "shouldBe" to see them
var buf = null;
var idx = 0;

function runTest()
{
    gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
    gl.enable(gl.BLEND);
    gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
    // Bind the texture to texture unit 0
    gl.bindTexture(gl.TEXTURE_2D, texture);
    // Point the uniform sampler to texture unit 0
    gl.uniform1i(textureLoc, 0);
    // Draw the triangles
    wtu.drawQuad(gl, [0, 0, 0, 255]);

    // Spot check a couple of 2x2 regions in the upper and lower left
    // corners; they should be the rgb values in the texture.
    color = [0, 0, 0];
    debug("Checking lower left corner");
    wtu.checkCanvasRect(gl, 1, gl.canvas.height - 3, 2, 2, color,
                        "shouldBe " + color);
    debug("Checking upper left corner");
    wtu.checkCanvasRect(gl, 1, 1, 2, 2, color,
                        "shouldBe " + color);

    successfullyParsed = true;
    var epilogue = document.createElement("script");
    epilogue.onload = finish;
    epilogue.src = "../../js/resources/js-test-post.js";
    document.body.appendChild(epilogue);
}

function finish() {
    if (window.nonKhronosFrameworkNotifyDone) {
        window.nonKhronosFrameworkNotifyDone();
    }
}
</script>
</head>
<body onload="init()">
<canvas id="example" width="32px" height="32px"></canvas>
<div id="description"></div>
<div id="console"></div>
</body>
</html>
