OpenWindowedScreen() and alpha transparency

Mac OSX specific forum
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 528
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

OpenWindowedScreen() and alpha transparency

Post by Mindphazer »

It seems there's a problem with alpha tranparency in a OpenWindowedScreen on MacOS.
The sample code below displays 20 squares with increasing alpha transparency.
It works fine on Windows
But on MacOS (MacBook pro M4, MacOS 26.2, PB 6.21), all squares are white, no transparency is applied.

Code: Select all

InitSprite()
OpenWindow(0, 0, 0, 330, 160, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, DesktopScaledX(330), DesktopScaledY(160))

Repeat
  Repeat
    Event = WindowEvent()
    If event = #PB_Event_CloseWindow
      End 
    EndIf
  Until Event = 0
  If StartDrawing(ScreenOutput())
    DrawingMode(#PB_2DDrawing_AlphaBlend)
    For i = 1 To 20
      Box(DesktopScaledX(i * 15), DesktopScaledY(50), DesktopScaledX(14), DesktopScaledY(14), RGBA(255, 255, 255, 255 - (i * 10)))
    Next i
    StopDrawing()
  EndIf
  FlipBuffers() 
  ClearScreen(0)
ForEver
Can anybody else confirm ?
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 26.1 - Iphone 17 Pro Max - iPad at home
...and unfortunately... Windows at work...
mrbungle
Enthusiast
Enthusiast
Posts: 179
Joined: Wed Dec 30, 2020 3:18 am

Re: OpenWindowedScreen() and alpha transparency

Post by mrbungle »

Confirmed on macOS 15.73 (Seqouia)
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 528
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: OpenWindowedScreen() and alpha transparency

Post by Mindphazer »

I re-read the doc (!!)
Drawingmode(#PB_2DDrawing_AlphaBlend) is supposed to work only with ImageOutput(), CanvasOutput() and SpriteOutput()
So my code is not supposed to work :mrgreen:
I guess it's pure luck if it works on Windows :wink:
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 26.1 - Iphone 17 Pro Max - iPad at home
...and unfortunately... Windows at work...
User avatar
moulder61
Enthusiast
Enthusiast
Posts: 217
Joined: Sun Sep 19, 2021 6:16 pm
Location: U.K.

Re: OpenWindowedScreen() and alpha transparency

Post by moulder61 »

@Mindphazer,

It works on Linux. :P

Having said that, the help on ScreenOutput() says, under "Remarks" :
On Linux and OS X, ScreenOutput() copies the whole screen buffer back to main memory to do 2D drawing operations (OpenGL doesn't allow direct buffer access). Therefore drawing on a screen is very slow and should be avoided. ScreenOutput() has to be called in the same thread where OpenScreen() was called.
The use of InitEngine3D() is forbidden, ScreenOutput() returns 0.
Would that make a difference?

Moulder.
"If it ain't broke, fix it until it is!

This message is brought to you thanks to SenselessComments.com

My PB stuff for Linux: "https://u.pcloud.link/publink/show?code ... z3MR0T3jyV
Post Reply