Murga-Projects Forums
Timing and drawing ... UPDATED - Printable Version

+- Murga-Projects Forums (
+-- Forum: Project Forums (/forumdisplay.php?fid=1)
+--- Forum: MurgaLua - General (/forumdisplay.php?fid=2)
+--- Thread: Timing and drawing ... UPDATED (/showthread.php?tid=59)

Timing and drawing ... UPDATED - JohnMurga - 06-27-2007 08:16 AM


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




RE: Timing and drawing ... UPDATED - mikshaw - 06-27-2007 10:21 AM


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