Solved: Creating WindowedScreen fails on Catalina OS, PB572

Mac OSX specific forum
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Solved: Creating WindowedScreen fails on Catalina OS, PB572

Post 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
Last edited by Saki on Tue Jun 02, 2020 5:32 pm, edited 1 time in total.
地球上の平和
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: Creating WindowedScreen fails on Catalina OS and PB 5.7

Post 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
地球上の平和
User avatar
mk-soft
Always Here
Always Here
Posts: 5393
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Creating WindowedScreen fails on Catalina OS and PB 5.7

Post 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
Last edited by mk-soft on Tue Jun 02, 2020 4:01 pm, edited 1 time in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: Creating WindowedScreen fails on Catalina OS and PB 5.7

Post by Saki »

Hi, many thanks for testing mk-soft

Its my old machine i think

Best regards Saki
地球上の平和
User avatar
mk-soft
Always Here
Always Here
Posts: 5393
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Creating WindowedScreen fails on Catalina OS and PB 5.7

Post 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.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: Creating WindowedScreen fails on Catalina OS and PB 5.7

Post 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
地球上の平和
Post Reply