Page 1 of 1

Rapid Graphics Drawing

Posted: Wed Feb 08, 2012 6:11 am
by chris319
I want to see the numbers in this program increment at a rapid rate:

Code: Select all

OpenWindow(1, 100, 100, 400, 400, "")
CreateImage(1, 400, 400)

For mc = 1 To 100
StartDrawing(ImageOutput(1))
DrawText(100,100, Str(mc))
StopDrawing()
StartDrawing(WindowOutput(1))
DrawImage(ImageID(1), 0, 0)
StopDrawing()
Next

Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
FreeImage(1)
CloseWindow(1)
If I set mc to increment to 1000, the screen goes white until the loop has finished counting. On OS X, how can I see the numbers count up to 1000, i.e. rapid graphics refresh?

Re: Rapid Graphics Drawing

Posted: Wed Feb 08, 2012 6:05 pm
by WilliamL
...bad practice

Code: Select all

OpenWindow(1, 100, 100, 400, 400, "")
CreateImage(1, 400, 400)

For mc = 1 To 100
StartDrawing(ImageOutput(1))
DrawText(100,100, Str(mc))
StopDrawing()
StartDrawing(WindowOutput(1))
DrawImage(ImageID(1), 0, 0)
StopDrawing()
While WindowEvent():Wend
;While WaitWindowEvent(10):Wend ; for a delay
Next

Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
FreeImage(1)
CloseWindow(1)

Re: Rapid Graphics Drawing

Posted: Thu Feb 09, 2012 9:14 pm
by chris319
Thanks William.

I had a loop with WaitWindowEvent() waiting for window events. By changing it to WaitWindowEvent(1), adding a 1 ms timeout, the graphics became responsive.