title: How to pass huge array to shader on iOS with OpenGL ES 2.0?
body: <p>I just need pass a huge array (count 1521) of <code>Int</code> to shader for my animation.
  Firstly, I treat it as a uniform, but it seems too huge as uniform.</p>
  
  <p>Then, I found that <a href="https://stackoverflow.com/questions/7954927/glsl-passing-a-list-of-values-to-fragment-shader">Passing a list of values to fragment shader</a> 
  I don't enough reputation for comment, so I have to open another question. I am not familiar with those APIs, I tried all of them</p>
  
  <ul>
  <li>1D Textures:  I can't find any API which works.</li>
  <li>Uniform Buffer Objects:  Most examples are clear and understandable, but it's not available on iOS with ES 2.0</li>
  <li>Buffer Textures: I think it's very close, but glTexBuffer and GL_TEXTURE_BUFFER seems missing on iOS with ES 2.0</li>
  <li>Shader Storage Buffer Objects: That's something for GL 4.3, it's too new for ES 2.0</li>
  </ul>
  
  <p>Please help me, I just need to access that array in shader.</p>
  
  <p>That's what I am doing:</p>
  
  <pre><code>// i var
  GLint *randomArray; 
  GLuint _randomArrayTexture;
  GLuint _randomArrayUnifrom;
  
  // init texture
  randomArray = (GLint*)malloc(1521 * sizeof(GLint)); 
      for (int i=0; i&lt;1521; i++) {
          randomArray[i] = array[i].intValue;
      }
  
  glGenTextures(0, &amp;_randomArrayTexture);
  glBindTexture(GL_TEXTURE_2D, _randomArrayTexture);
  
  glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 1521, 1, 0, GL_ALPHA, GL_INT, randomArray);
  glBindTexture(GL_TEXTURE_2D, 0);
  
  _randomArrayUnifrom = glGetUniformLocation(_program, "randomArray"); // after shader compiled
  
  // before draw
  glActiveTexture(GL_TEXTURE1);
  glBindTexture(GL_TEXTURE_2D, _randomArrayTexture);
  glUniform1i(_randomArrayUnifrom, 1);
  glBindTexture(GL_TEXTURE_2D, 0);
  
  // the thing in shader
  uniform sampler2D randomArray;
  texture2D(randomArray, vec2(0.1, 0.0)); 
  // Could I access the texture with real index (not uniformed) such as vec2(1109, 0)
  </code></pre>