SDL_RenderPresent fails without previous SDL_Delay

Hello list!

I’m having an issue that’s supposed to be long solved.
Here’s the link to the original thread (2011):

http://sdl.5483.n7.nabble.com/Very-first-call-to-RenderPresent-does-nothing-X11-OpenGL-td30382.html

In short, a call to |SDL_RenderPresent()| fails if there’s no delay
between it and |SDL_CreateWindow|.

The following code creates a window that only shows red after the first
delay has passed:

|#include “SDL.h”

int main(int argc, char* argv[])
{
SDL_Window* window;
SDL_Renderer* renderer;

     if (SDL_Init(SDL_INIT_VIDEO) < 0) return -1;

     window = SDL_CreateWindow("Empty Red Window",
                     SDL_WINDOWPOS_CENTERED,
                     SDL_WINDOWPOS_CENTERED,
                     512, 512,
                     SDL_WINDOW_SHOWN);

     renderer = SDL_CreateRenderer(window, -1, 0);

     /* Select red color and 'clear' with it */
     SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
     SDL_RenderClear(renderer);

     /* Update screen for the first time and wait */
     SDL_RenderPresent(renderer);
     SDL_Delay(5000);

     /* Update screen second time and wait some more */
     SDL_RenderPresent(renderer);
     SDL_Delay(5000);

     SDL_Quit();
     return 0;

}|

Now, I know this might have something to do with tiling window managers, as
pointed out in the thread. I’m using /AwesomeWM/ on an Arch Linux box.

I’ve had this issue on Arch Linux’s precompiled repository, the stable
release
right from |libsdl.org| and the Mercurial repository.
Here’s a detailed list of my steps:

http://alexdantas.net/stuff/posts/cant-make-sdl2-work-at-all/