title: OpenGL Shader Compile Error
body: <p>I'm having a bit of a problem with my code for compiling shaders, namely they both register as failed compiles and no log is received. </p>
  
  <p>This is the shader compiling code:</p>
  
  <pre><code>/* Make the shader */
  
  Uint size;
  GLchar* file;
  
  loadFileRaw(filePath, file, &amp;size);
  
  const char * pFile = file;
  const GLint pSize = size;
  
  
  newCashe.shader = glCreateShader(shaderType);
  glShaderSource(newCashe.shader, 1, &amp;pFile, &amp;pSize); 
  glCompileShader(newCashe.shader);
  
  GLint shaderCompiled;
  
  glGetShaderiv(newCashe.shader, GL_COMPILE_STATUS, &amp;shaderCompiled);
  
  if(shaderCompiled == GL_FALSE)
  {
      ReportFiler-&gt;makeReport("ShaderCasher.cpp", "loadShader()", "Shader did not compile", "The shader " + filePath + " failed to compile, reporting the error - " + OpenGLServices::getShaderLog(newCashe.shader));
  
  }
  </code></pre>
  
  <p>And these are the support functions:</p>
  
  <pre><code>bool loadFileRaw(string fileName, char* data, Uint* size)
  {    
      if (fileName != "") 
      {
          FILE *file = fopen(fileName.c_str(), "rt");
  
          if (file != NULL) 
          {
              fseek(file, 0, SEEK_END);
              *size = ftell(file);
              rewind(file);
  
              if (*size &gt; 0) 
              {
                  data = (char*)malloc(sizeof(char) * (*size + 1));
                  *size = fread(data, sizeof(char), *size, file);
                  data[*size] = '\0';
              }
  
              fclose(file);
          }
      }
  
      return data;
  }
  
  string OpenGLServices::getShaderLog(GLuint obj)
  {
      int infologLength = 0;
  
      int charsWritten  = 0;
      char *infoLog;
  
      glGetShaderiv(obj, GL_INFO_LOG_LENGTH,&amp;infologLength);
  
      if (infologLength &gt; 0)
      {
          infoLog = (char *)malloc(infologLength);
          glGetShaderInfoLog(obj, infologLength, &amp;charsWritten, infoLog);
  
          string log = infoLog;
  
          free(infoLog);
  
          return log;
      }
  
      return "&lt;Blank Log&gt;";
  }
  </code></pre>
  
  <p>and the shaders I'm loading:</p>
  
  <pre><code>void main(void)
  {
      gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
  }
  
  void main(void)
  {
      gl_Position = ftransform();
  }
  </code></pre>
  
  <p>In short I get</p>
  
  <pre><code>From: ShaderCasher.cpp, In: loadShader(), Subject: Shader did not compile
  Message: The shader Data/Shaders/Standard/standard.vs failed to compile, reporting the error - &lt;Blank Log&gt;
  </code></pre>
  
  <p>for every shader I compile.</p>
  
  <p>I've tried replacing the file reading with just a hard coded string but I get the same error so there must be something wrong with how I'm compiling them. I have run and compiled example programs with shaders, so I doubt my drivers are the issue, but in any case I'm on a Nvidia 8600m GT.</p>
  
  <p>Can anyone help?</p>