Hi everybody,
I am working on a small Tile-Engine with SDL. Everything works quite fine exept of the termination of the application. I know that my program gets the SDL_QUIT event and tries to shut down the application, but it won’t. The main graphics-window closes down as it should, but the process is still running in the background and I have to quit it via Task-Manager.
Here the most important parts out of main:
SDL_Surface *screen;
SDL_TimerID timerid;
…
//Initialize the SDL subsystems
if( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0 )
{
printf(SDL_GetError());
return 0;
}
atexit(SDL_Quit);
printf(“SDL initialized successfully\n”);
screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, PDEPTH, \
SDL_HWSURFACE|SDL_DOUBLEBUF);
if ( screen == NULL )
{
printf(“Couldn’t initialize SDL: %s\n”, SDL_GetError());
return FALSE;
}
printf(“SDL video-mode successfully initialized\n”);
…
// Set the timer to 30 ms
timerid = SDL_AddTimer(30, UpdateAndDraw, &data);
//Run
while(data.done == FALSE)
{
//…
}//*/
// quit the timer
SDL_RemoveTimer(timerid);
SDL_FreeSurface(screen);
screen = NULL;
// shutdown the game, free all the data like textures
Shutdown();
return 1;
}
I know that data.done gets set when I press Escape as it should, so the error should be somewhere below the loop. I also tried to run the program without initializing the timer and without the loop, but no success, still the same problem as before.
Hope you can help me, I don’t want to have a program which is not even able to quit correctly.
If it helps:
My OS: Windows
Compiler is DevC++ 4.9.9.2
SDL-Libs 1.2.4 are used—
Thanks
Jan Brinker