function Reset(gl) {
gl.canvas.width += 1;
gl.canvas.width -= 1;
}
function ReadCenterPixel(gl) { var w = gl.drawingbufferWidth; var h = gl.drawingbufferHeight; var ret = new Uint8Array(4);
gl.readPixels(w/2, h/2, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, ret);
return ret;
}
function Test(gl, prog) {
gl.enable(gl.BLEND);
gl.blendFunc(gl.ZERO, gl.DST_ALPHA);
var dataURL_pre = gl.canvas.toDataURL();
//console.log('Before blending: ' + dataURL_pre);
DrawSquare(gl, prog, 0.7);
var pixel = ReadCenterPixel(gl);
ok(pixel[0] == iColor &&
pixel[1] == iColor &&
pixel[2] == iColor, 'Color should be the same.');
ok(pixel[3] == 255, 'No-alpha should always readback as 1.0 alpha.');
var dataURL_post = gl.canvas.toDataURL();
//console.log('After blending: ' + dataURL_post);
ok(dataURL_post == dataURL_pre, 'toDataURL should be unchanged after blending.');
var pixel = ReadCenterPixel(gl);
ok(pixel[0] == iColor &&
pixel[1] == iColor &&
pixel[2] == iColor, 'Color should be the same.');
ok(pixel[3] == 255, 'No-alpha should always readback as 1.0 alpha.');
ok(gl.getError() == 0, 'Should have no errors.');
dataURL_post = gl.canvas.toDataURL();
//console.log('After blending: ' + dataURL_post);
ok(dataURL_post == dataURL_pre, 'toDataURL should be unchanged after blending.');
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.