Terminate not called after SDL_SetVideoMode() with SDL_OPENGL?

Started by
-1 comments, last by VBStrider 12 years, 3 months ago
This is a somewhat strange bug. The following code works fine:

#include <SDL.h>
#include <windows.h>
#include <exception>

void term()
{
MessageBox(NULL, "Terminate", "Debug", MB_OK);
abort();
}

int SDL_main(int argc, char *argv[])
{
set_terminate(term);

SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);

throw (0);
SDL_SetVideoMode(800, 600, 0, SDL_OPENGL);

return (0);
}


However, in this version of the code term() is never called:

#include <SDL.h>
#include <windows.h>
#include <exception>

void term()
{
MessageBox(NULL, "Terminate", "Debug", MB_OK);
abort();
}

int SDL_main(int argc, char *argv[])
{
set_terminate(term);

SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);

SDL_SetVideoMode(800, 600, 0, SDL_OPENGL);
throw (0);

return (0);
}


The only difference between the two pieces of code is that in the broken one, I am throwing the exception after calling SDL_SetVideoMode() rather than before it. Another thing to note is that the second example works if I remove the SDL_OPENGL flag.

I am compiling with Microsoft Visual C++ 2005, I am using SDL version 1.2.15 although I have also tested it with version 1.2.14 and the problem still exists, and I am running it on Windows XP SP3 Home. My graphics card is an ATI Radeon X1300 PRO, and my computer completely supports up to OpenGL 2.1. I have the latest graphics card drivers.

I suspect the issue is related to passing the exception from C++ code to C code (SDL 1.2.15 is written in C, but my program is written in C++), but if possible I'd like to know exactly what is going wrong.

This topic is closed to new replies.

Advertisement