Page 1 of 1
Solved: Creating WindowedScreen fails on Catalina OS, PB572
Posted: Tue Jun 02, 2020 9:47 am
by Saki
Hi,
can you try this.
Crashes, but not at every run, but almost always on Catalina MacOS and PB 5.72
Best regards Saki
Code: Select all
InitSprite()
Define wID=OpenWindow(1 , 0 , 0 , 100 , 100 , "" , #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(1) , 0 , 0 , 100 , 100)
; The creation of the screen fails, so StartDrawing fails, but not at every run
If Not StartDrawing(ScreenOutput())
Debug "Fail"
End
EndIf
StopDrawing()
Debug "OK"
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Re: Creating WindowedScreen fails on Catalina OS and PB 5.7
Posted: Tue Jun 02, 2020 1:16 pm
by Saki
Its very strange, so it works :
Added #PB_Window_Invisible , thats all
Code: Select all
InitSprite()
Define wID=OpenWindow(#PB_Any , 0 , 0 , 100 , 100 , "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_Invisible)
OpenWindowedScreen(WindowID(wID) , 0 , 0 , 100 , 100)
; The creation of the screen fails, so StartDrawing fails, but not at every run
If Not StartDrawing(ScreenOutput())
Debug "Fail"
End
EndIf
StopDrawing()
Debug "OK"
HideWindow(wID, 0)
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
Re: Creating WindowedScreen fails on Catalina OS and PB 5.7
Posted: Tue Jun 02, 2020 2:54 pm
by mk-soft
Always check if the function was successful ...
It's work (PB example)
Update
Code: Select all
If InitSprite() = 0
MessageRequester("Error", "Can't open screen & sprite environment!", 0)
End
EndIf
If OpenWindow(0, 0, 0, 220, 160, "A screen in a window...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0, 170, 135, 45, 20, "Quit")
; Dispatch Events befor open screen
While WindowEvent() : Wend
If OpenWindowedScreen(WindowID(0), 0, 0, 160, 160)
CreateSprite(0, 20, 20)
If StartDrawing(SpriteOutput(0))
Box(0, 0, 20, 20, RGB(255, 0, 155))
Box(5, 5, 10, 10, RGB(155, 0, 255))
StopDrawing()
EndIf
Else
MessageRequester("Error", "Can't open windowed screen!", 0)
End
EndIf
EndIf
direction = 2
Repeat
; Es ist sehr wichtig, alle im Queue befindlichen Ereignisse während jedes Frames abzuarbeiten
;
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_Gadget
If EventGadget() = 0
End
EndIf
Case #PB_Event_CloseWindow
End
EndSelect
Until Event = 0
FlipBuffers()
ClearScreen(RGB(0, 0, 0))
DisplaySprite(0, x, x)
x + direction
If x > 140 : direction = -2 : EndIf
If x < 0 : direction = 2 : EndIf
Delay(1)
ForEver
Re: Creating WindowedScreen fails on Catalina OS and PB 5.7
Posted: Tue Jun 02, 2020 3:53 pm
by Saki
Hi, many thanks for testing mk-soft
Its my old machine i think
Best regards Saki
Re: Creating WindowedScreen fails on Catalina OS and PB 5.7
Posted: Tue Jun 02, 2020 4:05 pm
by mk-soft
I don't think your machine is too old, because Catalina running on your machine.
It failed once with me too. Maybe you have to process all events before creating the screen.
Code above an update.
Re: Creating WindowedScreen fails on Catalina OS and PB 5.7
Posted: Tue Jun 02, 2020 4:18 pm
by Saki
Hi, thanks mk-soft,
it is strange, it fails, but its not important, init with #PB_Window_Invisible and it works fine.
I have another codes that uses the screen that worked,
so I could easily compare to find fast the cause.
Best regards Saki