Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


Terminate not called after SDL_SetVideoMode() with SDL_OPENGL?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 Michael Grand   Members   -  Reputation: 243

Like
0Likes
Like

Posted 21 January 2012 - 04:49 PM

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.

Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS