Posts: 28
Joined: Fri Sep 20, 2013 10:29 pm

SDL_CreateWindow() fails on second call

Wed Aug 14, 2019 7:54 pm

Hi all, so here is the situation. The code base I am working on currently is nearly identical to the code base here: https://github.com/vurtun/nuklear/tree/ ... _opengles2.

What I would like to do is within the same instance of the program fully initialize and delete an SDL+GLES instance twice within the run time of the same program. I have adapted the code base posted above to simply call the contents of main() twice with a slight pause in between. However on the second run SDL_CreateWindow() returns NULL. The error code returned is as follows: "Could not initialize OpenGL / GLES library".

I believe this is probably something to do with the way I am cleaning up SDL. Perhaps I am not cleaning it up properly. Here is the code I use to clean up SDL+Opengles (taken directly from the code base listed above):

Code: Select all

Could anyone shed some light on this issue for me? Thank you!

Posts: 417
Joined: Fri Nov 03, 2017 4:36 pm

Re: SDL_CreateWindow() fails on second call

Mon Aug 19, 2019 11:05 pm

A hunch based on my experience with SDL years ago: I don't think you should be creating windows after calling SDL_Quit().

SDL can be used for creating multiple windows or even multiple GL contexts, but you may have to refactor your program such that SDL_Init() and SDL_Quit() are both called exactly once.

Return to “Graphics programming”