• Advertisement
Sign in to follow this  

Terminate not called after SDL_SetVideoMode() with SDL_OPENGL?

This topic is 2190 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

This is a somewhat strange bug. The following code works fine:
[code]
#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);
}
[/code]

However, in this version of the code term() is never called:
[code]
#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);
}
[/code]

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.

Share this post


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

  • Advertisement