Hi all,

I'm just getting into webGL and want to start loading binary data directly into buffers instead of translating JSON into arrayBuffers. I can load the data correctly into a buffer but when I try and set that buffer as current I get this error in Chrome:

Uncaught TypeError: Type error


Here's a code snippet, the webGL parts are based off Lesson 1:

Code :
function onLoad()
{
	var canvas = document.getElementById("lesson01-canvas");
	initGL(canvas);
 
	var xmlhttp = new XMLHttpRequest();
	xmlhttp.open("GET", "cube.bm", true);
	xmlhttp.responseType = "arraybuffer";
 
	xmlhttp.onload = function() 
	{
		var buffer = xmlhttp.response;
		gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
 
		// Reading Data
		var v1 = new Float32Array(buffer);
 
		alert(v[0]);  // This works fine.
	}
	xmlhttp.send();
 
}

I guess I need a solid example of how to give the result of a binary XMLHttpRequest into an arrayBuffer correctly. This is a Chrome only thing, I know that Firefox has a different way of requesting binary data at the moment.

Thanks!

Ram