title: Arrays in GLSL on Android
body: <p>Trying to figure out why my vertex shader works on my cell phone (Casio Commando, Android 2.3.3), but then testing it on my tablet (Motorola Xoom, Android 3.2.4) it doesn't work...</p>
  
  <p>The vertex shader:</p>
  
  <pre><code>uniform mat4 uMVPMatrix;
  uniform mat4[4] uBoneMatrix;
  attribute vec4 vPosition;
  attribute vec4 vBoneIndex;
  attribute vec4 vBoneWeight;
  
  void main() {
   gl_Position = uMVPMatrix * ( (vBoneWeight.x * uBoneMatrix[int(vBoneIndex.x)]) +
                                (vBoneWeight.y * uBoneMatrix[int(vBoneIndex.y)]) +
                                (vBoneWeight.z * uBoneMatrix[int(vBoneIndex.z)]) +
                                (vBoneWeight.w * uBoneMatrix[int(vBoneIndex.w)]) ) * vPosition;
  }
  </code></pre>
  
  <p>The <code>glGetShaderInfoLog()</code> on my tablet prints:</p>
  
  <pre><code>(2) : error C7551: OpenGL first class arrays require #version 120
  </code></pre>
  
  <p>The project targets android-8, and I am calling <code>setEGLContextClientVersion(2)</code>. On the tablet <code>GL_VERSION</code> is <code>OpenGL ES 2.0</code>, and on the phone it's <code>OpenGL ES 2.0.1566933</code>. <code>GL_SHADING_LANGUAGE_VERSION</code> on both devices is <code>OpenGL ES GLSL 1.00</code>.</p>
  
  <p>Even stranger is when I do prepend the <code>#version 120</code> line to my shader then I get even more errors:</p>
  
  <pre><code>(2) : error C0201: unsupported version 120
  (3) : error C7532: global type mat4 requires "#version 100" or later
  (4) : error C7551: OpenGL first class arrays require #version 120
  (5) : error C7532: global type vec4 requires "#version 100" or later
  (10) : error C7532: global variable gl_Position requires "#version 100" or later
  (10) : error C7532: global type int requires "#version 100" or later
  </code></pre>
  
  <p>So I guess it's just a discrepancy between the drivers? It seems odd to me that the driver on the tablet knows about adding <code>#version 120</code> and then complains when I do add it.</p>