Rapid Graphics Drawing

Mac OSX specific forum
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Rapid Graphics Drawing

Post 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?
WilliamL
Addict
Addict
Posts: 1259
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Re: Rapid Graphics Drawing

Post 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)
MacBook Pro-M1 (2021), Tahoe 26.2, PB 6.30b6
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: Rapid Graphics Drawing

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