SDL_QuitRequested() weird bug

Hi

I’m trying to use exactly this piece of code to start my main loop (on
Windows + Codeblocks)

while(!SDL_QuitRequested()){

}

and it works fine…but I discovered that when I “play” with the window
(minimizing,giving and taking the focus,etc) a few times, the app doesn’t
respond when I try to close it. Any ideas?

also I’ve been looking everywhere…looks like SDL_QuitRequested it’s not
very popular…

the thing is I was trying to not use polling…I even tried to use
SDL_PeepEvents + SDL_PumpEvents but the same weird bug happens.-----
Vladimir

FWIW, “polling” means what you are doing. You are regularly asking if
some state exists outside of your program (your code) rather than
depending on a list of “events” which you can react to, in order to
modify your program’s state.

There’s been a lot of discussion on events. Check it out, yoOn Mon, Aug 3, 2009 at 1:34 AM, Vladimir wrote:

while(!SDL_QuitRequested()){

the thing is I was trying to not use polling…I even tried to use
SDL_PeepEvents + SDL_PumpEvents but the same weird bug happens.


http://codebad.com/

You have to remove events from the event queue or it will fill. There
are a few ways of interacting with the event queue. A simple, empty
PollEvent() loop will work. You can also use SDL_PeepEvents() and
SDL_PumpEvents(), but that is unnecessarily complicated.

SDL_QuitRequested() is only a simple macro above Peep and Pump events
anyway: http://svn.libsdl.org/branches/SDL-1.2/include/SDL_quit.h

Can you tell us more about

  • why you want to avoid polling?

  • the bug you encounter even when clearing the event queueOn Mon, Aug 3, 2009 at 6:34 AM, Vladimir wrote:

Hi

I’m trying to use exactly this piece of code to start my main loop (on
Windows + Codeblocks)

also I’ve been looking everywhere…looks like SDL_QuitRequested it’s not
very popular…

the thing is I was trying to not use polling…I even tried to use
SDL_PeepEvents + SDL_PumpEvents but the same weird bug happens.

Hi, thank you for your quick responses

FWIW, “polling” means what you are doing. You are regularly asking if
some state exists outside of your program (your code) rather than
depending on a list of “events” which you can react to, in order to
modify your program’s state.

There’s been a lot of discussion on events. Check it out, yo

hahaha I didn’t knew that, I was trying to say that I didn’t wanted to use
SDL_PollEvent

You have to remove events from the event queue or it will fill. There

are a few ways of interacting with the event queue. A simple, empty
PollEvent() loop will work. You can also use SDL_PeepEvents() and
SDL_PumpEvents(), but that is unnecessarily complicated.

SDL_QuitRequested() is only a simple macro above Peep and Pump events
anyway: http://svn.libsdl.org/branches/SDL-1.2/include/SDL_quit.h

That actually fixed it!!! thanks!

http://svn.libsdl.org/branches/SDL-1.2/include/SDL_quit.h

Can you tell us more about

  • why you want to avoid polling?

  • the bug you encounter even when clearing the event queue

Well I had a class about SDL in college but my professor always used one or
two files and a BIG main loop ( C ) I’m trying to create a system suitable
for bigger projects and “class it up” in C++

In the end I ended creating a binary flag and using SDL_PollEvent to fill it
with events. So I can react to them in different methods. What do you think
about that?—
Vladimir

I don’t know about anyone else, but I didn’t understand what you were
saying here.On Mon, Aug 3, 2009 at 11:37 PM, Vladimir wrote:

In the end I ended creating a binary flag and using SDL_PollEvent to fill it
with events. So I can react to them in different methods. What do you think
about that?


http://codebad.com/