In my project I use SDL2 + OpenGL. There is simple code. Function
VPreRender() is called when I want to clear buffer and start to draw in it. After that, when I want to show this buffer on the screen, I use functions
When the program is started with integrated video card (HD Intel), the window does not blink when it appears. But when I start the program with High-performanced NVIDIA video card, it starts blinking for some seconds and then stops. Then it all looks fine. The same situation appears if I want to resize the window. So what I do wrong? Why is the window blinking?
I tried to capture this situation. SDL2/OPENGL WINDOW BLINKING
glClearColor(m_backgroundColor.r, m_backgroundColor.g, m_backgroundColor.b, m_backgroundColor.a);
glClear ( GL_COLOR_BUFFER_BIT );
Best How To :
The behavior you are describing is a typical symptom of calling the window system swap function multiple times per frame.
The result is that frames that you have not rendered are shown on the display. Say if the system uses plain double buffering, and you make two swap calls, the first swap call would present the buffer with the frame you rendered, but the immediately following second swap call would replace it with the other buffer, which could contain anything.
How buffers are handled during rendering and the desktop composition process is very system dependent. So it's not surprising that the exact symptoms are system dependent, or could even change over time. Blinking between valid and invalid frames is certainly one of the possibilities.
To avoid this, you need to make sure that you call
SDL_GL_SwapWindow() exactly once per frame, after you finished all your rendering.