[SDL] OS X + SDL_SetEventFilter = Bus Error

Zedr0n Zedr0nRE at gmail.com
Fri Jan 4 01:31:52 PST 2008


I have encapsulated the SDL init/drawing into a separate class and
use it with my console app. 

I'm trying to use dynamic resizing  by doing this

void Graph::drawGraph()
{
	SDL_Init(SDL_INIT_VIDEO); 									// initialize SDL
	SDL_SetEventFilter(eventFilter);
	SDL_SetVideoMode(WindowWidth,WindowHeight,0,
                                           SDL_OPENGL | SDL_RESIZABLE);
	SDL_WM_SetCaption(WindowName.c_str(),NULL);
	bool done = false;
	while(!done)
	{
		current_graph = this;
		drawGLScene();
		SDL_Event event;
		while(SDL_PollEvent(&event))
		{
			if(event.type == SDL_VIDEORESIZE)
			{
				WindowWidth = event.resize.w;
				WindowHeight = event.resize.h;
				SDL_SetVideoMode(event.resize.w,event.resize.h,
                                0,SDL_OPENGL|SDL_RESIZABLE);
			}			
		}
	}
	SDL_Quit();
}

The event filter is declared as a static member(so that it can be used as
a callback, i tried just the same with glut and it worked).

static int eventFilter(const SDL_Event *e)
{
	if(e->type == SDL_VIDEORESIZE)
	{
		SDL_SetVideoMode(e->resize.w,e->resize.h,
                0,SDL_OPENGL | SDL_RESIZABLE);
		current_graph->WindowWidth = e->resize.w;
		current_graph->WindowHeight = e->resize.h;
		current_graph->drawGLScene();
	}
	return 1;
}

The problem here is that the app fails with "Bus Error". I've hunted it down to
the SDL_SetVideoMode call i.e. if I remove the call, it resizes successfully
but naturally it doesn't draw what I need(although
it does draw because I call drawGLScene() from here).

Any idea what the problem is?

And just an additional question - is it normal that when I resize the
window it also gets centered?



More information about the SDL mailing list