I am porting a GPGPU script to WebGL. I am having problems getting the following code ported. THe original in C++ is:

glBindTexture(GL_TEXTURE_2D, DataArray);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
float * pixelstuff = new float[1024*1024*3];
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, Columns, Rows,
0, GL_RGB, GL_FLOAT, 0);

I have converted to WebGL as:


GLSLTexture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, GLSLTexture);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP);

defaultArray = new WebGLFloatArray(new WebGLArrayBuffer(3*512*512));
gl.texImage2D(gl.TEXTURE_2D, 0, GL_RGBA8, 512, 512, 0, GL_RGB, GL_FLOAT, defaultArray);

the last line where I try to define the texture's format is where things seem to fall apart. if I comment it out then things work fine (that is the rest of the code executes ok). Any thoughts would be appreciated.