title: GLSL : uniform buffer object example
body: <p>I have an array of GLubyte of variable size. I want to pass it to fragment shader. I have seen 
  <a href="https://stackoverflow.com/questions/7954927/glsl-passing-a-list-of-values-to-fragment-shader">This thread </a>  and <a href="https://stackoverflow.com/questions/20803961/opengl-glsl-using-buffer-objects-for-uniform-array-values">this thread</a>. So I decided to use "Uniform Buffer Objects". But being a newbie in GLSL, I do not know:</p>
  
  <p>1 - If I am going to add this to fragment shader, how do I pass size? Should I create a struct?</p>
  
  <pre><code>layout(std140) uniform MyArray
   { 
    GLubyte  myDataArray[size];  //I know GLSL doesn't understand GLubyte
   };
  </code></pre>
  
  <p>2- how and where in C++ code associate this buffer object ?</p>
  
  <p>3 - how to deal with casting GLubyte to  float?</p>