Advertisement Jump to content
Sign in to follow this  

sdl2 window flashes

This topic is 1798 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



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?



the tool chain I use is mingw.

the way I set them up goes like this:

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 this post

Link to post
Share on other sites

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 this post

Link to post
Share on other sites

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?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!