There are still issues with how OpenWindowedScreen works on MacOS (MacOS 10.15.5 and PB 5.72). Using the code posted at the end for testing:
1) On a "non-retina" screen connected to the Mac, everything works as expected, EXCEPT: mouse is captured, but is actually offset from the window so that when you click, you actually click on somewhere else on the desktop and your window loses focus. The mouse is "captured" off of the window, making Windowed Screens with captured mouse unusable.
2) On a "retina" screen (in-built laptop screen), a window of 500x500 is double the size of a screen of 500x500. This sort of makes sense, as the rendering surface is actually higher DPI, but the desktop DPI gets reported as 1.00, making it hard to adjust for.
3) On a "retina" screen, if you attempt to create the 2x resolution surface as above and then scale up the window to 2x size, the surface doesn't seem to scale with the window. The ClearScreen() still clears the entire window, but the mouse and ScreenOutput() drawing is clipped to the bottom-left quarter of the windowed screen?
I can attempt to explain better if needed.
Code:
EnableExplicit
Structure Point
x.f
y.f
EndStructure
Structure Platform
x1.f
y1.f
x2.f
y2.f
EndStructure
Declare CreatePlatform(x1.f, y1.f, x2.f, y2.f)
Declare CreateMouse()
; General pre-setup stuff / initializations
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0
MessageRequester("Startup error", "There was an error initializing the hardware. Exiting...")
End
EndIf
UsePNGImageDecoder()
; General constants
#SCREEN_WIDTH = 500
#SCREEN_HEIGHT = 500
ExamineDesktops()
If OpenWindow(0, 100, 100, #SCREEN_WIDTH/2, #SCREEN_HEIGHT/2, "PB DRAWING TEST", #PB_Window_ScreenCentered) = 0
MessageRequester("Startup error", "There was an error opening the window. Exiting...")
End
EndIf
; Open the screen for rendering...
If OpenWindowedScreen(WindowID(0),0,0, #SCREEN_WIDTH, #SCREEN_HEIGHT, 1, 0, 0, #PB_Screen_WaitSynchronization) = 0
MessageRequester("Startup error", "There was an error initializing rendering. Exiting...")
End
EndIf
CreateMouse();
ReleaseMouse(1)
Debug(Str(DesktopResolutionX()))
SetFrameRate(60)
Define e.i ; event handler
Define quit = #False
Define lastClick.Point
lastClick\x = 0
lastClick\y = 0
Global NewList platforms.Platform()
; initialize some test platforms
Define i.i
For i = 0 To 1000
CreatePlatform(Random(#SCREEN_WIDTH), Random(#SCREEN_HEIGHT), Random(#SCREEN_WIDTH), Random(#SCREEN_HEIGHT))
Next
;ReleaseMouse(#True)
Define MouseClicked.a = #False
ReleaseMouse(0)
;- Start the main loop -----------------------
Repeat
;- Process events loop ---------------------
Repeat
e = WindowEvent()
Select e
Case #PB_Event_CloseWindow
quit = #True
EndSelect
Until e = 0
;- Main game loop -------------------------
ExamineKeyboard()
ExamineMouse()
If MouseButton(#PB_MouseButton_Left)
If Not MouseClicked
; The mouse was clicked and we need to create another platform
CreatePlatform(lastClick\x, lastClick\y, MouseX(), MouseY())
lastClick\x = MouseX()
lastClick\y = MouseY()
MouseClicked = #True
EndIf
Else
MouseClicked = #False
EndIf
If KeyboardPushed(#PB_Key_Escape)
quit = #True
EndIf
If KeyboardPushed(#PB_Key_1 )
ResizeWindow(0, #PB_Ignore, #PB_Ignore, #SCREEN_WIDTH*2, #SCREEN_HEIGHT*2)
EndIf
;- Draw game
ClearScreen(RGB(0,0,Random(200)))
; Draw mouse
DisplayTransparentSprite(0,MouseX(),MouseY())
StartDrawing(ScreenOutput())
ForEach platforms()
platforms()\x1 = platforms()\x1 + 1
LineXY(platforms()\x1, platforms()\y1, platforms()\x2, platforms()\y2, $FFFFFF)
Next
StopDrawing()
FlipBuffers()
Until quit = #True
Procedure CreateMouse()
; CreateImage(0, 32, 32, 24, $000000)
; StartVectorDrawing(ImageVectorOutput(0))
; VectorSourceColor($000000)
; AddPathSegments("M 0 0 L 32 0 L 0 32 Z")
; FillPath()
; StopVectorDrawing()
; StartDrawing(SpriteOutput(0))
; DrawImage(0,0,0)
; StopDrawing()
; FreeImage(0)
LoadSprite(0, "assets/cursor_t.png",#PB_Sprite_AlphaBlending)
EndProcedure
Procedure CreatePlatform(x1.f, y1.f, x2.f, y2.f)
Define *p.Platform = AddElement(platforms())
With *p
\x1 = x1
\y1 = y1
\x2 = x2
\y2 = y2
EndWith
;Debug("Platform created.")
EndProcedure