[SDL] question about handling events

Jonathan Dearborn grimfang4 at gmail.com
Thu Jul 28 16:31:30 PDT 2011


Hi Ivan,

It's likely that even though your code is not very readable, it does
something that most of us have done many times before.  So don't be worried
about sharing if you think that will help solve your problem.  We may be
able to figure it out easier than you expect.

Are you using SDL_PollEvent()?  With that controlling an event loop, you can
handle events and display stuff as well.
E.g.
SDL_Event event;
Uint8 done = 0;
while(!done)
{
    while(SDL_PollEvent(&event))
    {
        if(event.type == SDL_QUIT)
            done = 1;
    }
    SDL_FillRect(screen, NULL, 0x000000);
    // Draw stuff here
    SDL_Flip(screen);
    SDL_Delay(1);
}

Jonny D


On Thu, Jul 28, 2011 at 6:34 PM, Ivan Radojkovic
<itsa.registers at gmail.com>wrote:

> Hi,
> I am new with SDL.
> I have written an intro to a game, but I cant figure out how to check for
> SDL_QUIT effectively while the animation is running. And the other issue is
> whenever I switch to another window the program stops responding and
> executing. I can give you the code but I am still a beginner and my code is
> not very readable.
> I searched for a solution for a while now but with no luck.
> Thank you in advance.
>                           Ivan Radojkovic
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20110728/c506689b/attachment-0008.htm>


More information about the SDL mailing list