News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.

Post Reply  Post Thread 
Timing and drawing ... UPDATED
Author Message

Posts: 381
Group: Administrators
Joined: Apr 2007
Status: Offline
Reputation: 2
Post: #1
Timing and drawing ... UPDATED


There has been a lot of conversation around timing and drawing ... Use of wait (which isn't at all reliable for timing), and nasty busy loops.

You will also find examples of the socket.sleep function, but this only gives you 1 second intervals ... murgaLua 0.5 will have a propper 1/1000 of a second sleep, and maybe timeouts, but what do you do now ...

Try this (updated draw demo)

delay = 0.1 -- Delay is rounded up to closest 0.2 of a second.
counter = 0

function draw_callback(eventValue)

      -- Linux will SOMETIMES segfault unless we set the display
      -- BEFORE doing any drawing related stuff ...

      -- Linux will segfault unless we set the font before using fl_draw
      fltk.fl_font(fltk.FL_COURIER, 20)
      fltk.fl_draw("this is a test",20,80+counter)

      fltk.fl_loop( 20,20,80+counter,80+counter, 200,0)

      if counter > 120 then counter=2 end


w=fltk:Fl_Window(0,0, 210, 220, "draw demo")

timer = fltk:Fl_Timer(FL_HIDDEN_TIMER, 0,0,0,0,"0")




This post was last modified: 06-27-2007 09:53 AM by JohnMurga.

06-27-2007 08:16 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Senior Member

Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #2
RE: Timing and drawing ... UPDATED


Now that animation is surely possible, i guess it's time to start playing around with some unnecessary eyecandy =o)

Thanks very much for this.
And thanks in advance for murgaLua.sleep()

06-27-2007 10:21 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: