   Shader
  Hi folks..I'm currently using ATI Radeon 7500 card on my eMac G4 machine which does not support fragment shaders. So I opted to use software renderer for running fragment shaders.Unfortunately, the renederer  doesnt allow me to use loops. It asks redeclaration...void main(){int NumOfTextures;int i;for (i=0;i< NumOfTextures; i++)gl_TexCoord = gl_ModelViewMatrix * gl_Vertex;}Error : Array must be redeclared with a size before being indexed with a variableHow should I redeclare ? As I'm not in a position to upgrade my graphics card, it would be of great help if any1 can tell me the answer.
  Not too sure, perhaps you should just declare vec2 gl_TexCoord[NumOfTextures]; before the main loop?   ;Quote:Original post by KumGameHi folks..I'm currently using ATI Radeon 7500 card on my eMac G4 machine which does not support fragment shaders. So I opted to use software renderer for running fragment shaders.Unfortunately, the renederer  doesnt allow me to use loops. It asks redeclaration...void main(){int NumOfTextures;int i;for (i=0;i< NumOfTextures; i++)gl_TexCoord = gl_ModelViewMatrix * gl_Vertex;}Error : Array must be redeclared with a size before being indexed with a variableHow should I redeclare ? As I'm not in a position to upgrade my graphics card, it would be of great help if any1 can tell me the answer.Well you can only have 8 texture coordinates on newer hardware and you will need to check if the 7500 has 8 texture coordinates also... Then you can put a constant 8 in your loop. Or you can try and send in a uniform to tell the shader how many units you are using e.g. 6. And last you can unroll the loop and just calculate all 8... HTH;  I tried.. The solution is hopeless :(It doesn't allow me to declare gl_TexCoord array before the loop. Something like vec4 gl_TexCoord[MaxTexture];I got error for the above declaration.As Mars suggested, now I'm using static methodgl_TexCoord[0], gl_TexCoord[1] so on... Thanks for replies :)   ;Quote:Original post by KumGameI tried.. The solution is hopeless :(It doesn't allow me to declare gl_TexCoord array before the loop. Something like vec4 gl_TexCoord[MaxTexture];I got error for the above declaration.As Mars suggested, now I'm using static methodgl_TexCoord[0], gl_TexCoord[1] so on... Thanks for replies :)So it works then with defined arrays...;  It works... But sad.. I got to repeat the same thing for all tex units.. Still, it works.Thnks again :)   ;  In order to do non-static loops, you need to have a shader model 3.0 card.   ;  It's not that, when GLSL links vertex and fragment shaders together it works out what is required uniform space wise, of which the gl_TexCoord[] array is part of.To do this the linker needs to know how high in the final array you are going to access, you do this by either statically accessing the array elements (gl_TexCoord[0] etc) or at the start of the fragment shader you declare uniform vec4 Tex_Coord[n] where 'n' is a static compile time value.Using either of these methods allows the GLSL linker to correctly allocate uniforms.   