title: SDL_RENDERER_PRESENTVSYNC Inconsistently Displays
body: <p>I've recently decided to dive into writing a C++ game using SDL as one of my libraries. During the course of my program writing and learning about SDL, I stumbled across a peculiar bug in my program, and decided to replicate it in an SSCCE to make sure that I wasn't crazy.</p>
  
  <p>The problem appears to be that when I pass SDL_RENDERER_PRESENTVSYNC as a flag to SDL_CreateRenderer, I get inconsistent rendering. To compare, I ran the program 50 times with, and 50 times without the flag, and made that the only change to my program in each case. Without the flag, the display worked 100% of the time. With the flag on, it only rendered successfully 13 out of the 50 times.</p>
  
  <p>Here's the program:</p>
  
  <pre><code>#include &lt;SDL2/SDL.h&gt;
  #include &lt;iostream&gt;
  
  int main(int argc, char** argv)
  {
      if(SDL_Init(SDL_INIT_VIDEO) != 0)
      {
          std::cerr &lt;&lt; "Unable to initialize SDL: " &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
          return -1;
      }
      SDL_Window* win = SDL_CreateWindow("Testing", 
                                         SDL_WINDOWPOS_UNDEFINED, 
                                         SDL_WINDOWPOS_UNDEFINED,
                                         640, 480, SDL_WINDOW_SHOWN);
      SDL_Renderer* renderer = SDL_CreateRenderer(win, -1, 
                                                  SDL_RENDERER_ACCELERATED | 
                                                  SDL_RENDERER_PRESENTVSYNC);
      SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
      SDL_RenderClear(renderer);
      SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
      for(int x = 0; x &lt; 640; x+=32)
      {
          for(int y = 0; y &lt; 480; y+=32)
          {
              SDL_Rect rect = {x+1, y+1, 31, 31};
              SDL_RenderFillRect(renderer, &amp;rect);
          }
      }
      SDL_RenderPresent(renderer);
      SDL_Delay(500);
      SDL_DestroyRenderer(renderer);
      SDL_DestroyWindow(win);
      SDL_Quit();
      return 0;
  }
  </code></pre>
  
  <p>If it makes a difference, I'm compiling and testing the program on Ubuntu 15.04, GCC/G++ 4.9.2, Compiled and linked against SDL 2.0.2. </p>
  
  <p>Being so new to SDL, and still relatively new to both C++ and C (I come from a Java background), I think it's very likely that I've made a simple error that I'm not catching, but I can't think of what I might have done.</p>