title: How to fix "GLSL 3.30 is not supported" error with SDL2
body: <p>I'm drawing a triangle on screen with OpenGL and SDL2.</p>
  
  <p>My problem resides at the shaders compiling stage.</p>
  
  <p>Here are the errors I get :</p>
  
  <blockquote>
    <p>ERROR::SHADER::VERTEX::COMPILATION_FAILED
    0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.40, 1.00 ES, and 3.00 ES</p>
    
    <p>ERROR::SHADER::FRAGMENT::COMPILATION_FAILED
    0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.40, 1.00 ES, and 3.00 ES</p>
    
    <p>ERROR::SHADER::PROGRAM::LINKING_FAILED
    error: linking with uncompiled/unspecialized shadererror: linking with uncompiled/unspecialized shader</p>
  </blockquote>
  
  <p>I saw on some forums people having the same error messages, and they were told that by default MESA will switch to compatibility profile instead of core profile, but the thing is that I've explicitly told SDL2 to create a core context profile :</p>
  
  <pre><code>SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
  </code></pre>
  
  <p>By the way, I've already used OpenGL version 3.30 with GLSL 3.30 on that same computer without any issues by using it with GLFW and GLAD, but now I just want to have it working with SDL2 and GLEW.</p>
  
  <p>Here is the result of the <code>glxinfo | grep "version"</code> command :</p>
  
  <pre><code>server glx version string: 1.4
  client glx version string: 1.4
  GLX version: 1.4
      Max core profile version: 3.3
      Max compat profile version: 3.1
      Max GLES1 profile version: 1.1
      Max GLES[23] profile version: 3.1
  OpenGL core profile version string: 3.3 (Core Profile) Mesa 19.1.7
  OpenGL core profile shading language version string: 3.30
  OpenGL version string: 3.1 Mesa 19.1.7
  OpenGL shading language version string: 1.40
  OpenGL ES profile version string: OpenGL ES 3.1 Mesa 19.1.7
  OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10
      GL_EXT_shader_implicit_conversions, GL_EXT_shader_integer_mix,
  </code></pre>
  
  <p>And the content of my main function :</p>
  
  <pre><code>int main(int argc, char* argv[])
  {
      // =====&gt; INIT VARS
      SDL_Window* window;
      SDL_Renderer* renderer;
      SDL_GLContext glContext;
      GLenum err;
      // INIT VARS &lt;=====
  
      if(SDL_Init(SDL_INIT_VIDEO) &lt; 0)
      {
          std::cout &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
          return -1;
      }
      SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
      SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
      SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
      SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
      SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
      SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
      SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
      SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
      SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
      SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
  
      window = createWindow(WIDTH, HEIGHT, "TP_PROGRAMMATION_3D");
      if(window == nullptr)
      {
          std::cout &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
          SDL_Quit();
          return -1;
      }
      renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
      if(renderer == nullptr)
      {
          std::cout &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
          SDL_DestroyWindow(window);
          SDL_Quit();
          return -1;
      }
  
      // OPENGL CONTEXT FOR THE WINDOW
      glContext = SDL_GL_CreateContext(window);
  
      // GLEW INIT
      err = glewInit();
      if(err != GLEW_OK)
      {
          std::cout &lt;&lt; glewGetErrorString(err) &lt;&lt; std::endl;
          SDL_GL_DeleteContext(glContext);
          SDL_DestroyRenderer(renderer); SDL_DestroyWindow(window);
          SDL_Quit();
          return -1;
      }
  
      // EVERYTHING'S FINE : TIME TO PAINT IT GREY
      glViewport(0, 0, WIDTH, HEIGHT);
      SDL_GL_SetSwapInterval(1);
      glClearColor(Color::LIGHT_GREY[0], Color::LIGHT_GREY[1], Color::LIGHT_GREY[2], Color::LIGHT_GREY[3]);
  
      // OPENGL DRAWING CALLS AND MAIN DRAWING LOOP
      draw_gl(window);
  
      // END
      SDL_GL_DeleteContext(glContext);
      SDL_DestroyRenderer(renderer);
      SDL_DestroyWindow(window);
      SDL_Quit();
  
      return 0;
  }
  </code></pre>
  
  <p>And the shader code:</p>
  
  <pre><code>const char* vertexShaderSource = "#version 330 core\n"
  "layout (location = 0) in vec3 aPos;\n"
  "void main()\n"
  "{\n"
  "   gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);\n"
  "}";
  
  const char* fragmentShaderSource = "#version 330 core\n"
  "out vec4 color;\n"
  "void main()\n"
  "{\n"
  "   color = vec4(1.0f, 1.0f, 0.0f, 1.0f);\n"
  "}";
  </code></pre>