Painting on different platforms
Posted: Sun Oct 25, 2009 11:24 am
Hi all,
recently there was a small discussion on the German forum, which IMHO is of some general interest.
Let's for instance look at the example code of Circle() in the help (I always refer to PB 4.40 Beta 5 here):
On Windows (tested with XP x86), the code runs as expected, and paints some colored circles.
However, on Ubuntu 9.04 I only get an empty gray window, although this example code also is in the help of the PB Linux version.
On the German forum, user #Null suggested to change the code, so that the painting is done in the event loop on a #PB_Event_Repaint event. Indeed, the following code works as expected for me on Ubuntu 9.04:
Is it officially recommended by the PB team to write the code this way on Linux? If so, the example code in the docs should be modified accordingly.
Regards, Little John
recently there was a small discussion on the German forum, which IMHO is of some general interest.
Let's for instance look at the example code of Circle() in the help (I always refer to PB 4.40 Beta 5 here):
Code: Select all
Width=200
Height=150
If OpenWindow(0, 0, 0, Width, Height, "Circles", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If StartDrawing(WindowOutput(0))
x = Width/2
y = Height/2
For Radius = Height/2 To 10 Step -10
Circle(x, y, radius ,RGB(Random(255),Random(255),Random(255)))
Next
StopDrawing()
EndIf
Repeat : Event = WaitWindowEvent() : Until Event = #PB_Event_CloseWindow
EndIf
However, on Ubuntu 9.04 I only get an empty gray window, although this example code also is in the help of the PB Linux version.
On the German forum, user #Null suggested to change the code, so that the painting is done in the event loop on a #PB_Event_Repaint event. Indeed, the following code works as expected for me on Ubuntu 9.04:
Code: Select all
Define Width, Height, Event, x, y, Radius
Width = 200
Height = 150
If OpenWindow(0, 0, 0, Width, Height, "Circles", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) = 0
Debug "OpenWindow() failed."
EndIf
Repeat
Event = WaitWindowEvent()
Select event
Case #PB_Event_Repaint
If StartDrawing(WindowOutput(0))
x = Width/2
y = Height/2
For Radius = Height/2 To 10 Step -10
Circle(x, y, radius, RGB(Random(255), Random(255), Random(255)))
Next
StopDrawing()
EndIf
EndSelect
Until Event = #PB_Event_CloseWindow
Regards, Little John