Event loop as a separate thread?

Is there any way to do this:

CallAVeryLongFunctionThatDrawsStuff();

//do this at the same time (so you can exit the program before the long
function is done)
while(SDL_PollEvent(&event)) {
		switch(event.type){
			case SDL_KEYDOWN:
                                exit(0);
				break;
			case SDL_QUIT:
				exit(0);
				break;
		}
	}

Thanks,

Dave–
View this message in context: http://www.nabble.com/Event-loop-as-a-separate-thread--tp22658298p22658298.html
Sent from the SDL mailing list archive at Nabble.com.

I think you should be able to draw to a software surface from any thread.On Mon, Mar 23, 2009 at 7:25 AM, daviddoria wrote:

Is there any way to do this:

CallAVeryLongFunctionThatDrawsStuff();
>
> //do this at the same time (so you can exit the program before the long
> function is done)
> while(SDL_PollEvent(&event)) {
> ? ? ? ? ? ? ? ?switch(event.type){
> ? ? ? ? ? ? ? ? ? ? ? ?case SDL_KEYDOWN:
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?exit(0);
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?break;
> ? ? ? ? ? ? ? ? ? ? ? ?case SDL_QUIT:
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?exit(0);
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?break;
> ? ? ? ? ? ? ? ?}
> ? ? ? ?}

Thanks,

Dave

View this message in context: http://www.nabble.com/Event-loop-as-a-separate-thread--tp22658298p22658298.html
Sent from the SDL mailing list archive at Nabble.com.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


http://codebad.com/

That’s not to say you shouldn’t lock it!On Tue, Mar 24, 2009 at 9:10 AM, Donny Viszneki <@Donny_Viszneki> wrote:

I think you should be able to draw to a software surface from any thread.


http://codebad.com/

Just as long as you remember that SDL_LockSurface() has nothing to do
with mutual exclusion. You will still need to use synchronisation
primitives to protect shared resources.

Regards,
Brian.On Tue, Mar 24, 2009 at 1:10 PM, Donny Viszneki <donny.viszneki at gmail.com> wrote:

On Tue, Mar 24, 2009 at 9:10 AM, Donny Viszneki <donny.viszneki at gmail.com> wrote:

I think you should be able to draw to a software surface from any thread.

That’s not to say you shouldn’t lock it!