title: Unable to Use the OpenGL Core Profile and Create and OpenGL 4.x Context
body: <p>I am trying to develop simple OpenGL applications using the programmable pipeline, specifically using OpenGL 4.2+, but my programs seem to be stuck using OpenGL 3.0 and GLSL 1.30.</p>
  
  <p>The output from <code>glxinfo |grep "OpenGL"</code> on my Ubuntu 18.04 machine is as follows:</p>
  
  <pre><code>OpenGL vendor string: Intel Open Source Technology Center
  OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 520 (Skylake GT2) 
  OpenGL core profile version string: 4.5 (Core Profile) Mesa 18.0.5
  OpenGL core profile shading language version string: 4.50
  OpenGL core profile context flags: (none)
  OpenGL core profile profile mask: core profile
  OpenGL core profile extensions:
  OpenGL version string: 3.0 Mesa 18.0.5
  OpenGL shading language version string: 1.30
  OpenGL context flags: (none)
  OpenGL extensions:
  OpenGL ES profile version string: OpenGL ES 3.2 Mesa 18.0.5
  OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
  OpenGL ES profile extensions:
  </code></pre>
  
  <p>I've created a simple program which I believe should initialise an OpenGL 4.2 context:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;GL/glew.h&gt;
  #include &lt;GL/freeglut.h&gt;
  #include &lt;glm/glm.hpp&gt;
  #include &lt;glm/gtc/matrix_transform.hpp&gt;
  
  using namespace std;
  
  
  int main(int argc, char** argv)
  {
      glutInit(&amp;argc, argv);
      glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH);
      glutInitWindowSize(600, 600);
      glutCreateWindow("OpenGL Test");
      glutInitContextVersion (4, 2);
      glutInitContextProfile (GLUT_CORE_PROFILE);
  
      if(glewInit() == GLEW_OK)
      {
          cout &lt;&lt; "GLEW initialization successful! " &lt;&lt; endl;
          cout &lt;&lt; "Using GLEW version " &lt;&lt; glewGetString(GLEW_VERSION) &lt;&lt; 
  endl;
      }
      else
      {
          cerr &lt;&lt; "Unable to initialize GLEW  ...exiting." &lt;&lt; endl;
          exit(EXIT_FAILURE);
      }
  
      cout &lt;&lt; glGetString(GL_VERSION) &lt;&lt; endl;
      cout &lt;&lt; glGetString(GL_SHADING_LANGUAGE_VERSION) &lt;&lt; endl;
  }
  </code></pre>
  
  <p>However, when I run this program the following output is printed to the console, showing the the OpenGL version used is 3.0 and the GLSL version used is 1.3.</p>
  
  <pre><code>GLEW initialization successful! 
  Using GLEW version 2.0.0
  3.0 Mesa 18.0.5    # OpenGL version
  1.30               # GLSL Version
  </code></pre>
  
  <p>I am compiling and running my program as follows:</p>
  
  <pre><code>g++ OpenGLTest.cpp -o OpenGLTest -lglut -lGLU -lGL -lGLEW
  ./OpenGLTest
  </code></pre>
  
  <p>What I am doing wrong or what else could I try to fix this?</p>