Re: Need Help with Musubi Demo
- Posted by euphoric (admin) Oct 22, 2010
- 1252 views
Updated program now times drawing primitives for Musubi. HOWEVER, there must be something wrong because I get very low numbers compared to my wxEuphoria drawing primitives demo. It's a significant difference, and I would have thought SDL would be drawing faster since that's what it's meant to do...
I suspect it's the same problem I had when I originally developed the wxEuphoria drawing test... I was bottle-necking it somewhere. I originally tried using a Musubi/SDL timer, but couldn't get that to work. That's probably the problem. :(
Here's the wxEuphoria version for comparison.
-- Musubi demo that can be used to benchmark the drawing of graphical primitives include std/search.e include std/sequence.e without warning include musubi/musubi.ew as mus integer counter, maxX, maxY, gmode, stopped = 1 atom TIMER, timer integer timing, drawDots, drawLines, drawShapes, drawFilled, last_count timing = (1=2) drawDots = (1=2) drawLines = (1=2) drawShapes = (1=2) drawFilled = (1=2) last_count = 0 procedure init() M_init() -- initialize Musubi M_set_screen_mode(windowed) -- windowed M_set_window_caption("Drawing Primitives Benchmark") -- * 640x480 graphics, mimic the euphoria mode 256 gmode=graphics_mode(256) maxX = 640 maxY = 480 -- * Manual updating is faster M_set_update_mode(manual) TIMER = M_ticks() + 1000 end procedure procedure fini() M_cleanup() end procedure procedure do_draw() sequence points integer numPoints counter += 1 M_string(BLACK,{268,8},sprintf("Draws per second: %d",{last_count})) if drawDots then points = {rand(maxX),rand(maxY)} mus:pixel(10,points) end if if drawLines then points = {{rand(maxX),rand(maxY)},{rand(maxX),rand(maxY)}} draw_line(BLUE, points ) end if if drawShapes then points = {} numPoints = 3 for t=1 to numPoints do points &= {rand(maxX) & rand(maxY)} end for polygon(12, 0, points ) end if if drawFilled then points = {} numPoints = 3 for t=1 to numPoints do points &= {rand(maxX) & rand(maxY)} end for polygon(11, 1, points ) end if if M_ticks() >= TIMER then TIMER = M_ticks() + 1000 last_count = counter counter = 0 end if M_string(BRIGHT_WHITE,{268,8},sprintf("Draws per second: %d",{last_count})) M_update() end procedure sequence pressed = {} procedure ToggleDrawing(sequence keys) integer already_timing already_timing = timing if find('d',keys) > 0 then -- start/stop the dots drawDots = not drawDots if find('d',pressed) = 0 then pressed &= 'd' end if else pressed = remove_all( 'd', pressed ) end if if find_any("lL",keys) > 0 then -- start/stop the lines if find_any("lL",pressed) = 0 then drawLines = not drawLines pressed &= 'l' -- letter el end if else pressed = remove_all( 'l', pressed ) end if if find_any("eE",keys) > 0 then -- start/stop the empty triangles if find_any("eE",pressed) = 0 then drawShapes = not drawShapes pressed &= 'e' end if else pressed = remove_all( 'e', pressed ) end if if find_any("fF",keys) > 0 then -- start/stop the filled triangles if find_any("fF",pressed) = 0 then drawFilled = not drawFilled pressed &= 'f' end if else pressed = remove_all( 'f', pressed ) end if timing = drawDots or drawLines or drawShapes or drawFilled if timing then do_draw() else counter = 0 last_count = 0 TIMER = M_ticks() + 1000 end if end procedure procedure do_test() sequence keys while find(SDLK_ESCAPE,keys) = 0 with entry do entry keys = M_read_keys() ToggleDrawing(keys) end while end procedure procedure main() init() do_test() fini() end procedure main()