title: What is an SDL renderer?
body: <p>I'm starting with SDL2 and having some trouble trying to understand what an SDL_Renderer is.</p>
  
  <p>What is it? What does it do? What's the difference between SDL_Renderer, SDL_Window, SDL_Surface and SDL_Texture and how they are related?</p>
  
  <p>I had issues with this when trying to understand  this introductory code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;SDL2/SDL.h&gt;
  
  int main()
  {
      /* Starting SDL */
      if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
          std::cout &lt;&lt; "SDL_Init Error: " &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
          return 1;
      }
  
      /* Create a Window */
      SDL_Window *window = SDL_CreateWindow("Hello World!", 100, 100, 640, 480, SDL_WINDOW_SHOWN);
      if (window == nullptr) {
          std::cout &lt;&lt; "SDL_CreateWindow Error: " &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
          return 1;
      }
  
      /* Create a Render */
      SDL_Renderer *render = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
      if (render == nullptr) {
          std::cout &lt;&lt; "SDL_CreateRenderer Error: " &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
          return 1;
      }
  
      /* Load bitmap image */
      SDL_Surface *bmp = SDL_LoadBMP("./Tutorial/res/Lesson1/hello.bmp");
      if (bmp == nullptr) {
          std::cout &lt;&lt; "SDL_LoadBMP Error: " &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
          return 1;
      }
  
      /* Upload surface to render, and then, free the surface */
      SDL_Texture *texture = SDL_CreateTextureFromSurface(render, bmp);
      SDL_FreeSurface(bmp);
      if (texture == nullptr){
          std::cout &lt;&lt; "SDL_CreateTextureFromSurface Error: " &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
          return 1;
      }
  
      /* Draw the render on window */
      SDL_RenderClear(render); // Fill render with color
      SDL_RenderCopy(render, texture, NULL, NULL); // Copy the texture into render
      SDL_RenderPresent(render); // Show render on window
  
      /* Wait 2 seconds */
      SDL_Delay(5000);
  
      /* Free all objects*/
      SDL_DestroyTexture(texture);
      SDL_DestroyRenderer(render);
      SDL_DestroyWindow(window);
  
      /* Quit program */
      SDL_Quit();
      return 0;
  }
  </code></pre>
  
  <p>I was using Twinklebear tutorial (suggested on SDL Wiki) and looked also on SDL Wiki Documentation and some books. But all of them assume that I know these definitions. </p>