Setting the pixel format properties after you create your context is pretty pointless. The pixel format of the default framebuffer is immutable once the context is created.
Move all your calls to SDL_GL_SetAttribute (...)
so that they come before SDL_GL_CreateContext(window)
.
The swap interval can be set at any time, but everything else in this block of code needs to be moved:
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
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_SetSwapInterval(1);
Right now, you are probably getting a single-buffered pixel format. That does not jive well with modern window managers, which only update individual windows when you swap back/front buffers. Buffer swapping causes an implicit flush (whether or not it swaps buffers), so this problem is most likely due to a compositing window manager.