[SDL] Re: Timed functions.

Santiago Romero nop at todolinux.org
Tue Apr 25 09:03:19 PDT 2000


>>  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

 Ok, although the timer is quite limited (10ms), It is enough for me
 (f=50Hz -> T=20ms)...

>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.

  do you mean treating the keys just in the main
 loop (after detecting a SDL_KEYDOWN message?)...

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

 what kind of emulator? :)

>>  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 !
 
 I don't understand what SDL_MapRGB() does... :(  You pass it the
 pixel format of the dest surface, and ... it's supposed to build
 a "color palette" for non-palette modes? :? I see... I'm testing
 it... yes, it works :) nice, every day SDL surprises me :)
 
>Programmer
>Loki Entertainment Software

 I think the Linux world will have lots of reasons to be very grateful
 to Loki E.S. if SDL continues being developed this way... I've never
 used SDL and I'm learning it in just a few weeks, when it took 2 months
 to learn just directdraw... It's amazing what SDL can do and how has
 returned me to my "programming days"  :)
 
> "Microsoft has done to computers what McDonald's has done to gastronomy"

 X'DDD I'll add it to my RANDSIG signature generator :)
 
     http://www.ctv.es/USERS/sromero/prog/randsig.html

 CU (and thx a lot!).

-- 
ULTIMAS NOTICIAS: Programador encontrado muerto en la ducha con
una botella de champú donde ponía: "Lavar, aclarar, repetir".

 _-----------------------------------------------------_
|  NoP / Compiler          --       nop @ todolinux.org |
|-------------------------------------------------------|
|  POWERED BY - Linux RedHat 6.0  -  Reg. User #74.821  |
|             http://www.ctv.es/USERS/sromero           |
 ~-----------------------------------------------------~



More information about the SDL mailing list