title: GLEW + SDL Missing OpenGl Version
body: <p>I am attempting to get C++ to work with SDL2 and OpenGl on Ubuntu Linux 16.10 x64. When I run my code, I get a "Missing GL version" error. When I search through Google and Stack Exchange I find limited information that applies to my situation. The few "solutions" I find do not work.</p>
  
  <p>List of some of the resources I have already checked:</p>
  
  <ul>
  <li><a href="https://www.opengl.org/discussion_boards/showthread.php/163694-glew-Missing-GL-Version-error" rel="nofollow noreferrer">https://www.opengl.org/discussion_boards/showthread.php/163694-glew-Missing-GL-Version-error</a></li>
  <li><a href="https://stackoverflow.com/questions/14276444/failed-to-initialize-glew-missing-gl-version">Failed to Initialize GLEW. Missing GL version</a> </li>
  <li><a href="https://stackoverflow.com/questions/26074793/glew-initialisation-failed-missing-gl-version-glfw">Glew initialisation failed : Missing GL version (GLFW)</a></li>
  <li><a href="http://en.sfml-dev.org/forums/index.php?topic=10262.0" rel="nofollow noreferrer">http://en.sfml-dev.org/forums/index.php?topic=10262.0</a></li>
  </ul>
  
  <p>The common theme in my research seems to be that I am not properly specifying my OpenGl version, but, I am attempting to do so with my calls to <code>SDL_GL_SetAttribute</code>. It also seems to be a common theme that my context is not properly selected, but, calling <code>SDL_GL_MakeCurrent</code> has no effect.</p>
  
  <p>In addition to this, I have a gtx 1070 with the Nvidia binary blob drivers from the Ubuntu repositories (additional drivers dialog) installed, so, I doubt having the actual OpenGl verion I am requesting available is an issue either. Furthermore, other OpenGl programs (ie. Minecraft) work without issue. </p>
  
  <p>Lastly, very similar code works just fine on other computers (that very similar code does not work on my present computer), and it even gets so far as to create and initalize an OpenGl context correctly on an older computer that does not have my required OpenGl version supported -- those older computers fail later when an unsupported function is called.</p>
  
  <p>What am I doing incorrectly?</p>
  
  <p>I have the following code:</p>
  
  <pre><code>#include &lt;SDL2/SDL.h&gt;
  #include &lt;GL/glew.h&gt;
  #include &lt;sstream&gt;
  
  int main(int argc, char *argv[]){
      SDL_Init(SDL_INIT_EVERYTHING);
  
      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_CONTEXT_MAJOR_VERSION, 3);
      SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
  
      SDL_Window *m_window = SDL_CreateWindow(
              "test",
              SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
              800, 600,
              SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE
      );
  
      SDL_GLContext m_glContext = SDL_GL_CreateContext(m_window);
      SDL_GL_MakeCurrent(m_window, m_glContext); //tried without this code
  
      glewExperimental = GL_TRUE;
  
      int c = glewInit();
      if(c != GLEW_OK){
          std::ostringstream sout;
          sout &lt;&lt; "Failed to initialize GLEW: " &lt;&lt; glewGetErrorString(c);
  
          throw std::runtime_error(sout.str());
      }
  
  
  }
  </code></pre>