SDL_PollEvent not working

I’m guessing its how I’m using it. I tried using most of the other I/O stuff and it is extremely slow. I was talking to people on #SDL irc.freenode.net and I was told to try using SDL_PollEvent. The function works fine… alone… but when I use SDL_BlitSurface and SDL_UpdateRect for some reason it stops working. Does SDL_PollEvent need to be looping in its own process or something? Why doesn’t this code below work? Does anyone see a problem? Any help would be really appreciated. Here is a snippet of my code:

while(1) {
SDL_PollEvent(&event);
c = sdl_getchar(&event);
printf("%c", c);
SDL_BlitSurface((*txte->crnt), NULL, screen, &txte->rct);
SDL_UpdateRect(screen, 0, 0, 0, 0);
}

To follow the path:
look to the master,
follow the master,
walk with the master,
see through the master,
become the master.---------------------------------
Do you Yahoo!?
Yahoo! Hotjobs: Enter the “Signing Bonus” Sweepstakes

I just loop until I run out of events to deal with. e.g.:

do
{
while (SDL_PollEvent(&event) > 0)
{
… handle the event(s) …
}

do the rest of my crap for this frame

}
while (!done);

-bill!On Wed, Jan 07, 2004 at 05:54:50PM -0800, Hudson T. Clark wrote:

I’m guessing its how I’m using it. I tried using most of the other I/O stuff and it is extremely slow. I was talking to people on #SDL irc.freenode.net and I was told to try using SDL_PollEvent. The function works fine… alone… but when I use SDL_BlitSurface and SDL_UpdateRect for some reason it stops working. Does SDL_PollEvent need to be looping in its own process or something?

SDL_PollEvent return 1 when there’s an event to process. You are not
even checking if it’s 1 or 0.

Second: what about the kind of event it returned ? It can be an expose
or an syswm event or another.

Try something like:

while(1) {
if (SDL_PollEvent(&event) == 1) {
if (event.type == SDL_KEYDOWN) {
c = sdl_getchar(&event);
printf("%c", c);
}
} else {
SDL_BlitSurface((*txte->crnt), NULL, screen, &txte->rct);
SDL_UpdateRect(screen, 0, 0, 0, 0);
}
}

Do not update screen when there are “update” events pending. You will
add more events and will never get your screen updated. This is a common
mistake when you get out the “while SDL_PollEvent=1” method.

BTW, if it’s speed what you want, change the last line to something like:

SDL_UpdateRect(screen, txte->rct.x, txte->rct.y, txte->rct.w, txte->rct.h);

It will only update what you are painting.

http://pa.yahoo.com/*http://us.rd.yahoo.com/hotjobs/mail_footer_email/evt=21482/*http://hotjobs.sweepstakes.yahoo.com/signingbonus
Hudson T. Clark wrote:> I’m guessing its how I’m using it. I tried using most of the other I/O

stuff and it is extremely slow. I was talking to people on #SDL
irc.freenode.net and I was told to try using SDL_PollEvent. The
function works fine… alone… but when I use SDL_BlitSurface and
SDL_UpdateRect for some reason it stops working. Does SDL_PollEvent
need to be looping in its own process or something? Why doesn’t this
code below work? Does anyone see a problem? Any help would be really
appreciated. Here is a snippet of my code:

while(1) {
SDL_PollEvent(&event);
c = sdl_getchar(&event);
printf("%c", c);
SDL_BlitSurface((*txte->crnt), NULL, screen, &txte->rct);
SDL_UpdateRect(screen, 0, 0, 0, 0);
}

http://pa.yahoo.com/*http://us.rd.yahoo.com/hotjobs/mail_footer_email/evt=21482/*http://hotjobs.sweepstakes.yahoo.com/signingbonus