title: SDL2 OpenGL 4.2 context with 0 color bits and 0 depth bits
body: <p>I've been trying to start a new SDL + GLEW + OpenGL project, and the setup has been difficult (MinGW-w64-32 on Windows 8 64-bit with an Intel i7-4700MQ CPU and NVidia GTX 745M GPU).</p>
  
  <p>If I set the GL attributes to be used for context creation to use OpenGL version 4.2, the color and depth bit sizes get set to 0. However, if I request a 2.1 context (which is also the default), I can get the requested bit depths (8 bits for each color, 24 bits for depth). In either case, however, glClearColor has no effect (just a black background).</p>
  
  <p>In both cases, the result of a few <code>glGetString</code> calls is the same- a 4.2 context, suggesting SDL's output is far from correct.</p>
  
  <p>The entirety of the code can be found <a href="http://pastebin.com/C71uqJ5m" rel="nofollow">here</a>, it's mostly boilerplate for a larger project for now. The relevant sections would most likely be</p>
  
  <pre><code>if(SDL_Init(SDL_INIT_EVERYTHING) != 0) {
      std::cerr &lt;&lt; "Error initializing SDL.\n";
      exit(1);
  }
  
  SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
  //SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);
  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_DEPTH_SIZE, 24);
  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
  
  SDL_Window* window = SDL_CreateWindow("RenderSystem", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE);
  
  if(!window) {
      std::cerr &lt;&lt; "Window creation failed.\n";
      SDL_Quit();
      exit(2);
  }
  
  SDL_GLContext context = SDL_GL_CreateContext(window);
  
  if(!context) {
      std::cerr &lt;&lt; "OpenGL Context creation failed.\n";
      SDL_DestroyWindow(window);
      SDL_Quit();
      exit(3);
  }
  
  SDL_GL_MakeCurrent(window, context);
  </code></pre>
  
  <p>and</p>
  
  <pre><code>glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
  
  SDL_Event evt;
  bool run = true;
  
  while(run) {
  
      SDL_PollEvent(&amp;evt);
  
      switch(evt.type) {
          case SDL_KEYDOWN:
              if(evt.key.keysym.sym == SDLK_ESCAPE) {
                  run = false;
              }
              break;
  
          case SDL_QUIT:
              run = false;
              break;
      }
  
      SDL_GL_SwapWindow(window);
  
  }
  </code></pre>