SDL_WaitEvent() with expiration

Is there something equivalent to…

int SDL_TimedWaitEvent (SDL_Event *event, Uint32 expire)
{
int first_time = 1;
Uint32 start = SDL_GetTicks();
do {
if ( ! first_time ) {
if ( (SDL_GetTicks() - start) >= expire ) {
return(0);
}
SDL_Delay(10);
} else {
first_time = 0;
}
SDL_PumpEvents();
} while ( !SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_ALLEVENTS) );
return(1);
}

…in SDL that I just haven’t found yet?

Paul Braman
@Paul_Braman

Is there something equivalent to…

int SDL_TimedWaitEvent (SDL_Event *event, Uint32 expire)

There isn’t yet. Would it be helpful? It would essentially be your
sample implementation.

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

There isn’t yet. Would it be helpful? It would essentially be your
sample implementation.

In Bill Kendrick’s tutorial he advocates something like…

while (!done)
	start_cycle = SDL_GetTicks()
	poll_events
	handle_events
	if ((SDL_GetTicks() - start_cycle) < animation_interval)
		SDL_Delay(several_milliseconds)

…so that, if you need to at least do animation every 50 milliseconds it
will be in a delay until the next animation cycle if nothing major has
happened in the program.

I was thinking it would be more useful to be waiting for events during
this period to increase interactivity in the program.

Paul Braman
@Paul_BramanOn Sun, 9 Jan 2000, Sam Lantinga wrote:

In Bill Kendrick’s tutorial he advocates something like…

Wow! Someone read it! :wink:

while (!done)
start_cycle = SDL_GetTicks()
poll_events
handle_events
if ((SDL_GetTicks() - start_cycle) < animation_interval)
SDL_Delay(several_milliseconds)

…so that, if you need to at least do animation every 50 milliseconds it
will be in a delay until the next animation cycle if nothing major has
happened in the program.

Other’s like to do as much as they can per frame and then deal with movement
and stuff as a ratio to the framerate.

My reasoning for doing it the other way is 60, 50 and even 30fps are
plenty fast enough… there’s less math involved… and you’re not eating
up CPU more than you really need to.*

I was thinking it would be more useful to be waiting for events during
this period to increase interactivity in the program.

Ooooooh… That’s not a bad idea!

-bill!

  • Though I DO eat up CPU a lot doing other stuff. :slight_smile:

Hi everyone,

I’m trying to update the old aliens demo to work with the latest
mixer and img libs. I’ve gone through and built and installed the
mixer 1.0.1 and img 1.0.0 libs, then changed the necessary lines in
aliens.c and Makefile to bring the project up to date.

Compilation of aliens.c is successful, but with several warnings
which all look nearly alike (redundant text removed):

ld: Warning: type of symbol SDL_OpenAudio' changed from 2 to 1 in load.o SDL_PauseAudio SDL_LoadWAV_RW SDL_FreeWAV SDL_BuildAudioCVT SDL_MixAudio SDL_LockAudio SDL_UnlockAudio SDL_CloseAudio SDL_ReadLE16 SDL_ReadLE32 SDL_SetError SDL_CreateMutex SDL_mutexP SDL_mutexV SDL_DestroyMutex SDL_RWFromFile SDL_RWFromFP SDL_GetTicks SDL_Delay SDL_FreeSurface ld: Warning: type of symbolSDL_LoadBMP_RW changed from 2 to 1 in load.o

When I execute the resulting aliens binary, the error is simply:

Illegal Instruction (core dumped)

No SDL Parachute, no nothing…

I just updated to SDL 1.0.1. Any ideas what might be causing the warnings?

Thanks,

Steve Madsen
H2Eye Ltd
24-28 Hatton Wall
London EC1N 8JH
Tel: +44-171-404-9600
Fax: +44-171-404-9490
Email: @Steve_Madsen

Hi everyone,

I’m trying to update the old aliens demo to work with the latest
mixer and img libs. I’ve gone through and built and installed the
mixer 1.0.1 and img 1.0.0 libs, then changed the necessary lines in
aliens.c and Makefile to bring the project up to date.

Compilation of aliens.c is successful, but with several warnings
which all look nearly alike (redundant text removed):

Something is wrong. load.o doesn’t exist in SDL 1.0

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec