title: GLSL for-loop array index
body: <p>I'm having some trouble using variable indices in GLSL.
  The folowing GLSL code is working fine on NVidia cards. But its not working on my Intel HD 4000:</p>
  
  <pre><code>for(int i=0;i&lt;int(uLightCount);++i)
  {
      vec3 lightPos = uLightsPos[i];
      ....
  }
  </code></pre>
  
  <p>There is no Shader-Compiler Error. The program simply crashes on <code>glUseProgram</code></p>
  
  <p>How can I fix this?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p><code>uLightCount</code> and <code>uLightsPos</code> are uniforms:</p>
  
  <pre><code>#define MAX_LIGHTS 10
  uniform float uLightCount;
  uniform vec3 uLightsPos[MAX_LIGHTS];
  </code></pre>
  
  <p><strong>Edit 2:</strong></p>
  
  <p>I have found a strange workaround:</p>
  
  <pre><code>#define i0  0
  #define i1  1
  #define i2  2
  ...
  
  for(int i=0;i&lt;int(uLightCount);++i)
  {
      vec3 lightPos;
  
      if (i==i0) 
          lightPos = uLightsPos[i0];
      if (i==i1) 
          lightPos = uLightsPos[i1];
      ....
  }
  </code></pre>
  
  <p>Any idea why this is working?</p>