title: GLSL shader compilation on linux
body: <p>I'm trying to get my cross-platform shader to compile a default shader which is nothing more than the basic shader program like so:</p>
  
  <p>Vertex program:</p>
  
  <pre><code>void main()
  {
      //vec4 vertex = matModelView * a_vertex;
      gl_Position = ftransform();//matProj * vertex;
  
      gl_TexCoord[0] = gl_MultiTexCoord0;
  }
  </code></pre>
  
  <p>Fragment program:</p>
  
  <pre><code>uniform sampler2D colorMap;
  
  void main()
  {
      gl_FragColor = texture2D(colorMap, gl_TexCoord[0].st);
  }
  </code></pre>
  
  <p>I am aware that the gl_ prefix are deprecated functions but this is just a default shader so I know everything works. This sample works fine under windows with my shader class.</p>
  
  <p>Now onto my shader class, when I create a Shader object I call the load method which takes a path without a file extension. For example: ./data/shaders/default   The loader takes this and searches for that string + .vert .geom or .frag for the appropriate shader programs. These are then loaded and passed to the OpenGL part of creating the programs. This is where something seems to go wrong, I can confirm that the content of the shader programs is correctly loaded from disk so this is not where the problem lies as far as I can see.</p>
  
  <p>When the file is loaded it goes onto compiling the vertex and fragment programs (or geometry but this is optional):</p>
  
  <p><code>a_Type</code> is either <code>GL_FRAGMENT_SHADER</code> or <code>GL_VERTEX_SHADER</code>. <code>a_Source</code> is the content of the shader program file (the .vert/.frag/.geom file). When I load the vertex program the compilation instantly fails and <code>if( success != GL_TRUE )</code> is hit and evaluated as being so and I get a compilation error. I don get any output whatsoever, the "Shader compile output" printf doesn't print any info about compilation.  (The <code>OGLCHECK</code> is a macro which checks the opengl error stack, this doesn't show anything either.)</p>
  
  <pre><code>GLuint Shader::Compile(const GLuint a_Type, const char* a_Source)
  {
      if(a_Source == NULL)
          return 0;
  
      GLuint handle = glCreateShader(a_Type); OGLCHECK
      glShaderSource(handle, 1, &amp;a_Source, NULL); OGLCHECK
      glCompileShader(handle); OGLCHECK
  
      int bufflen = 0;
      GLint success = GL_FALSE;
  
      glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &amp;bufflen); OGLCHECK
      if(bufflen &gt; 1)
      {
          GLchar* logString = new GLchar[bufflen + 1];
          glGetShaderInfoLog(handle, bufflen, 0, logString); OGLCHECK
          printf( "Shader compile output:\n%s\n", logString );
  
          delete logString;
          logString = 0;
      }
  
      glGetShaderiv(handle, GL_COMPILE_STATUS, &amp;success); OGLCHECK
      if(success != GL_TRUE)
      {
          printf( "Failed to compile shader!\n" );
  
          glDeleteShader(handle); OGLCHECK
          handle = 0;
      }
  
      return handle;
  }
  </code></pre>
  
  <p>I'm unsure whats going on, this implementation works fine under windows as this is part of my rendering engine which I've ported to linux. Anyone had similar problems regarding shader compilation under linux?</p>
  
  <p>Also, I've checked glxinfo, here's some info:</p>
  
  <pre><code>glxinfo | grep "OpenGL version"
  OpenGL version string: 4.2.0 NVIDIA 295.49
  </code></pre>
  
  <p>I also grep'd on fragment_program, vertex_program, geometry_program and all these extension seem to be available. I'm running Ubuntu 12.04.</p>
  
  <p>Update:
  It seems its unrelated to the shaders files but something else, when I run it from a terminal its fine it compiles the shaders and uses them but whenever I run it from Code::Blocks it just fails to compile the shaders.. they are being loaded and passed to OpenGL. No clue whats going on.</p>