[SDL] Re: Timed functions.

Stephane Peter megastep at lokigames.com
Mon Apr 24 11:10:14 PDT 2000


In article <slrn8g5lpu.2g6.nop at compiler.linux.es>,
	nop at todolinux.org (Santiago Romero) writes:
> 
>  Hi!
>  SDL is fantastic: I've ported my SVGALIB emulator to SDL in just
>  2 hours (I'm developing an GPL spectrum emulator), but I have 
>  some questions...
>  
>  I want a function to be executed 50 times per second (it is the
>  function that updates the keyboard array and screen for my
>  emulator) and I don't know how to do this under SDL... ¿Must I
>  use a separate thread with a wait like SDL_Delay into it?

Your best bet is probably to use a SDL threaded timer (SDL_SetTimer() or
SDL_AddTimer() in SDL 1.1). Actually if you really just want to update
the keyboard array, it would probably be more efficient to do so only when
events are received, so you can use a SDL event filter for that.

I did write a SVGAlib emulator as well in the past ;-)

>  Another question is the "putpixel" example given on the SDL docs.
>  It is supposed to accept an Uint32 colour, but you must decide
>  before calling it the format of that colour, so you need extra
>  code. I've done the following, but I don't know if will work on
>  all platforms (I think BGR cards will show wrong colours):

You should probably call SDL_MapRGB() for that, passing the pixel format
structure from the surface you are using... It will do all the work for you !

-- 
Stephane Peter
Programmer
Loki Entertainment Software

   "Microsoft has done to computers what McDonald's has done to gastronomy"



More information about the SDL mailing list