title: Storing floats in a texture in OpenGL ES
body: <p>In WebGL, I am trying to create a texture with texels each consisting of 4 float values. Here I attempt to to create a simple texture with one <code>vec4</code> in it.</p>
  
  <pre><code>var textureData = new Float32Array(4);
  
  var texture = gl.createTexture();
  gl.activeTexture( gl.TEXTURE0 );
  gl.bindTexture(gl.TEXTURE_2D, texture);
  
  gl.texImage2D(
            // target, level, internal format, width, height 
            gl.TEXTURE_2D, 0, gl.RGBA, 1, 1,
            // border, data format, data type, pixels
            0, gl.RGBA, gl.FLOAT, textureData
        );
  </code></pre>
  
  <p>My intent is to sample it in the shader using a sampler like so:</p>
  
  <pre><code>uniform sampler2D data;
  ...
  vec4 retrieved = texture2D(data, vec2(0.0, 0.0));
  </code></pre>
  
  <p>However, I am getting an error during <code>gl.texImage2D</code>:</p>
  
  <pre><code>WebGL: INVALID_ENUM: texImage2D: invalid texture type
  WebGL error INVALID_ENUM in texImage2D(TEXTURE_2D, 0, RGBA, 1, 1, 0, RGBA, FLOAT,
  [object Float32Array])
  </code></pre>
  
  <p>Comparing the <a href="http://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexImage2D.xml" rel="nofollow">OpenGL ES spec</a> and the <a href="http://www.opengl.org/sdk/docs/man3/xhtml/glTexImage2D.xml" rel="nofollow">OpenGL 3.3 spec</a> for <code>texImage2D</code>, it seems like I am not allowed to use <code>gl.FLOAT</code>. In that case, how would I accomplish what I am trying to do?</p>