WebGL Texture Upload Test
Code sourced from http://codeflow.org/issues/slow_video_to_texture/
by dustinkerstein
HTML
<body>
<script>
window.onload = function() {
doload();
}
</script>
<div>
<button id="run">Run</button>
<progress id="progress" value="0"></progress>
<div id="result"></div>
</div>
<canvas id="canvas" style="opacity:.01"></canvas>
<script id="vertex-shader" type="vertex-shader">
attribute vec2 position;
attribute vec2 texcoord;
varying vec2 v_texcoord;
void main(void){
gl_Position = vec4(position, 0.0, 1.0);
v_texcoord = texcoord;
}
</script>
<script id="fragment-shader" type="fragment-shader">
precision lowp float;
varying vec2 v_texcoord;
uniform sampler2D image;
void main(void){
gl_FragColor = vec4(texture2D(image, v_texcoord).rgb, 1.0);
}
</script>
<script type="text/javascript">
console.log("initial load");
var progressBar = document.getElementById("progress");
var gettext = function (id) {
var elem = document.getElementById(id);
return elem.innerText || elem.textContent;
}
var create = function (name, parent, text) {
var e = document.createElement(name);
if (parent) {
parent.appendChild(e);
}
if (text) {
e.textContent = text;
}
return e;
}
var Statistics = function (id) {
this.init();
}
if (window.performance && performance.now) {
console.log('using: performance.now');
var gettime = function () { return performance.now() };
}
else {
console.log('using: Date.now');
var gettime = function () { return Date.now() };
}
if (window.requestAnimationFrame) {
console.log('using: requestAnimationFrame');
var raf = function (callback) {
requestAnimationFrame(callback);
}
}
else {
console.log('using: setTimeout');
var raf = function (callback) {
...