Page 1 of 1

examples: impossible to open a 800*600 32- bit screen

Posted: Thu Feb 26, 2026 1:05 am
by rootuid
I'm running PureBasic 6.30 - C Backend (MacOS X - arm64) on Tahoe 26.3 on a MacBook m2 with the default resolution of 1710 × 1112

examples/sources/WindowedScreen.pb & 2DDrawing.pb work fine but I have a problem with other example files. For example

Code: Select all

$ pbcompiler examples/sources/Mouse.pb --executable /tmp/test_mouse && /tmp/test_mouse
First I see a dialog with this text

Code: Select all

Information
This will test the fast keyboard access... Press 'ESC' to quit!
then it fails with

Code: Select all

Error
Impossible to open a 800*600 32- bit screen
same for
examples/sources/Keyboard.pb


I think the MacBook doesn't support that resolution and this might be the problem? Do the examples need to be updated to switch to a different resolution if not available?

Thanks in advance.

Re: examples: impossible to open a 800*600 32- bit screen

Posted: Thu Feb 26, 2026 10:52 am
by mk-soft
It is best to fill OpenScreen with the monitor resolution, 32-bit colour depth and all optional parameters.

Re: examples: impossible to open a 800*600 32- bit screen

Posted: Fri Feb 27, 2026 2:18 pm
by Fred
'Soft' full screen mode seems to be the way to go now, you could probably simulate this but opening a borderless fullscreen window and use OpenWindowedScreen().

Re: examples: impossible to open a 800*600 32- bit screen

Posted: Fri Feb 27, 2026 2:42 pm
by rootuid
thanks for the replies. What is soft full screen mode ?


It would be great if the examples were updated.

Re: examples: impossible to open a 800*600 32- bit screen

Posted: Fri Feb 27, 2026 3:03 pm
by mk-soft
Not at my Mac right now.

PB Example adapted...
A window in max size without a border.

Update for macOS with function EnterWindowFullscreen
You can swap screens with Ctrl-Left and Ctrl-Right

Code: Select all


; ------------------------------------------------------------
;
;   PureBasic - Window 3D
;
;    (c) Fantaisie Software
;
; ------------------------------------------------------------
;

CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
  ;--[ Window fullscreen procedures ]----------------------------------------------------------------

  Procedure EnableWindowFullscreen(window)
      NewCollectionBehaviour = CocoaMessage(0, WindowID(window), "collectionBehavior") | #NSWindowCollectionBehaviorFullScreenPrimary
      CocoaMessage(0, WindowID(window), "setCollectionBehavior:", NewCollectionBehaviour)
  EndProcedure
  
  Procedure ToggleWindowFullscreen(window)
      CocoaMessage(0, WindowID(window), "toggleFullScreen:", #nil)
  EndProcedure
  
  Procedure EnterWindowFullscreen(window)
      CocoaMessage(0, WindowID(window), "enterFullScreenMode:", #nil)
  EndProcedure
  
  Procedure ExitWindowFullscreen(window)
      CocoaMessage(0, WindowID(window), "exitFullScreenMode:", #nil)
  EndProcedure
  
  Procedure IsWindowFullscreen(window)
      #NSFullScreenWindowMask = 1 << 14
      ProcedureReturn Bool( CocoaMessage(0, WindowID(window), "styleMask") & #NSFullScreenWindowMask )
  EndProcedure
CompilerEndIf

#MainWindow = 0
#CloseButton = 0

Define.f KeyX, KeyY, MouseX, MouseY

InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()

ExamineDesktops()
dx = DesktopWidth(0)
dy = DesktopHeight(0)

If OpenWindow(0, 0,0, DesktopUnscaledX(dx),DesktopUnscaledY(dy), " Window 3D - [Esc] quit",#PB_Window_BorderLess | #PB_Window_Maximize)
  
  CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
    EnableWindowFullscreen(0)
    EnterWindowFullscreen(0)
  CompilerEndIf
  
  If OpenWindowedScreen(WindowID(0), 0, 0, dx, dy, 0, 0, 0)
  
    Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/GUI", #PB_3DArchive_FileSystem)
    Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Packs/desert.zip", #PB_3DArchive_Zip)
    
    SkyBox("desert07.jpg")
    
    CreateCamera(0, 0, 0, 100, 100)  ; Front camera
    MoveCamera(0,0,100,100, #PB_Absolute)
    
    
    OpenWindow3D(#MainWindow, 100, 100, 500, 200, "Hello in 3D !")
    
    ButtonGadget3D(#CloseButton, 150, 40, 200, 50, "Quit")
    
    ShowGUI(128, 1) ; Display the GUI, semi-transparent and display the mouse cursor
    
    Repeat
      While WindowEvent():Wend
      
      If ExamineKeyboard() And ExamineMouse()
        Input$ = KeyboardInkey()
        
        InputEvent3D(MouseX(), MouseY(), MouseButton(#PB_MouseButton_Left), Input$, 0)
      EndIf
      
      ; Handle the GUI 3D events, it's similar to regular GUI events
      ;
      Repeat
        Event = WindowEvent3D()
        
        Select Event
          Case #PB_Event3D_CloseWindow
            If EventWindow3D() = #MainWindow
              CloseWindow3D(#MainWindow)
            EndIf
            
          Case #PB_Event3D_Gadget
            If EventGadget3D() = #CloseButton
              Quit = 1
            EndIf
            
        EndSelect
      Until Event = 0
      
      RenderWorld()
      
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
    ExitWindowFullscreen(0)
  EndIf
EndIf

Re: examples: impossible to open a 800*600 32- bit screen

Posted: Fri Feb 27, 2026 4:48 pm
by mk-soft
Update for macOS with function EnterWindowFullscreen
You can swap screens with Ctrl-Left and Ctrl-Right