title: GLSL shaders and functions: error C1108
body: <p>I'm trying to write a basic vertex shader in GLSL and just for the sake of clarity, I'd like to add some functions to create matrices and perform other simple operations outside of the main() loop.</p>
  
  <p>However, when I try to execute: </p>
  
  <pre><code>uniform float scale;
  
  void main()
  {
  vec4 pos = gl_ProjectionMatrix * gl_Vertex;
  pos *= scaleMatrix(scale);
  
  gl_Position = pos;
  
  gl_TexCoord[0] = gl_MultiTexCoord0;
  
  gl_FrontColor = gl_Color;           
  } 
  
  mat4 scaleMatrix(const in float s) {
  return mat4(s, 0.0, 0.0, 0.0,
              0.0, s, 0.0, 0.0,
              0.0, 0.0, s, 0.0,
              0.0, 0.0, 0.0, 1.0 );
  }
  </code></pre>
  
  <p>I get the error: error C1008: undefined variable "scaleMatrix".
  However </p>
  
  <pre><code>uniform float scale;
  
  void main()
  {
  vec4 pos = gl_ProjectionMatrix * gl_Vertex;
  pos *= mat4(s, 0.0, 0.0, 0.0,
              0.0, s, 0.0, 0.0,
              0.0, 0.0, s, 0.0,
              0.0, 0.0, 0.0, 1.0 );
  
  gl_Position = pos;
  
  gl_TexCoord[0] = gl_MultiTexCoord0;
  
  gl_FrontColor = gl_Color;           
  } 
  </code></pre>
  
  <p>works just fine. Can anyone shed some light on this for me?</p>