[SDL] Well, me again having problems with the Key Events...
Manuel García Cabrera
manugarciac5 at yahoo.com.ar
Wed Jun 13 03:12:32 PDT 2007
Seems to be working now... I inverted the roles, now I check events in
the "non-thread" and do the other things in the thread (constantly
process and blit images). Thanks
Manuel García Cabrera escribió:
> No, I'm not calling PollEvents in the same thread I call SetVideoMode...
> Can that be the problem? And the enviar thing, don't worry about that...
>
> Doug escribió:
>> This is just an idea, as I'm not sure if this is your problem or not.
>>
>> Read this: http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fPumpEvents
>>
>> Notice two things:
>>
>> 1. SDL_PollEvent() calls SDL_PumpEvents() internally. So if you're calling
>> SDL_PollEvent() then SDL_PumpEvents() is being invoked implicitly.
>>
>> 2. SDL_PumpEvents() note: You can only call this function in the thread that
>> set the video mode.
>>
>> So, I'm wondering if the thread you call SDL_PollEvent() is the same thread
>> you used to set the video mode. If not, this may or may not be a problem for
>> you. I've called some SDL functions in threads and I got away with it - maybe
>> because I used a thread safe SDL function or I was just lucky.
>>
>> Unfortunately, I have not found a "master list" of which SDL functions are
>> thread-safe and which are not. Some are documented as such, but I'm not
>> convinced that all other SDL functions are thread safe.
>>
>>
>> The only other thing I noticed is this line:
>>
>> while ( SDL_PollEvent(&evento) || (enviar) ){
>>
>> This means you can enter your event handler if envair is true but
>> SDL_PollEvent() returned false. This means the code in the while loop may
>> possibly be accessing evento members that are not necessarily initialized to
>> meaningful values. Just a thought.
>>
>> Doug.
>>
>>
>> _______________________________________________
>> SDL mailing list
>> SDL at lists.libsdl.org
>> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
More information about the SDL
mailing list