title: OpenGL use uniform buffer as an array
body: <p>I found out that I can use uniform buffers to store multiple variables like this</p>
  <pre><code>#version 330 core
  layout (location = 0) in vec3 aPos;
  
  layout (std140) uniform Matrices
  {
      mat4 projection;
      mat4 view;
  };
  
  uniform mat4 model;
  
  void main()
  {
      gl_Position = projection * view * model * vec4(aPos, 1.0);
  }  
  </code></pre>
  <p>and treat this data like any other buffer</p>
  <pre><code>
  unsigned int uboMatrices
  glGenBuffers(1, &amp;uboMatrices);
    
  glBindBuffer(GL_UNIFORM_BUFFER, uboMatrices);
  glBufferData(GL_UNIFORM_BUFFER, 2 * sizeof(glm::mat4), NULL, GL_STATIC_DRAW);
  glBindBuffer(GL_UNIFORM_BUFFER, 0);
    
  glBindBufferRange(GL_UNIFORM_BUFFER, 0, uboMatrices, 0, 2 * sizeof(glm::mat4));
  </code></pre>
  <p>However, I can't seem to find any examples that would allow me to treat such a buffer like an array. Essentially I would like to achieve a global random-access buffer  like this</p>
  <pre><code>#version 330 core
  layout (location = 0) in vec3 aPos;
  
  layout (what here?) uniform float[] globalBuffer;
  
  uniform mat4 model;
  
  void main()
  {
      ...
  }  
  </code></pre>
  <p>The long term plan is to later produce this array with OpenCL</p>