# sdl2 window flashes

## Recommended Posts

ultramailman    1720

Hello.

Anyone notice how when a window is created using sdl2, it immediately closes and a new one is created again? It doesn't seem to have any negative effects, but it does bother me a little. What's going on here?

From what I can gather, sdl2 will try to use hardware rendering if possible, so my guess is the first time it makes a window for software rendering, then detects my computer can use hardware rendering, so it closes the window and creates a hardware rendering window. But that happens even if I specify the opengl flag.

Any ideas?

edit:

the tool chain I use is mingw.

the way I set them up goes like this:

SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_TIMER);
screen = SDL_CreateWindow("shooter game", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, window_width, window_height, 0);
renderer = SDL_CreateRenderer(screen, -1, 0);

Edited by ultramailman

##### Share on other sites
richardurich    1352

I only saw that when I was using Qt/qmake doing some tutorial or sample program or whatever, but I normally do not see it. I'm guessing that means it is either caused by the way you create the window, or by extra code injected by specific components of your toolchain. I didn't investigate the cause, so I just don't know what was happening.

Can you share the code you're using to create the window? You might just be creating a visible window to obtain an OpenGL context and destroying that. If so, just make it invisible (maybe SDL_WINDOW_SHOWN flag? sorry, not 100% sure since it's not code you type very often). Other than that random guess, I'd have to have more information to work with.

##### Share on other sites
DejaimeNeto    4221

It may be related to some "wizard created projects" with IDEs or maybe display reconfigurations on runtime, but is not how SDL2 works under normal circumstances.

Could you post the code where you create that window?