(Drawing commands have issues when drawing on a sprite created using CreateSprite() with the #PB_Sprite_AlphaBlending flag)
3rd Window opened in the code snippet requires a 256x256 image you can download here...
https://reelmedia.org/test/box.bmp
Code: Select all
InitSprite()
#screen=1
#sprite=2
If OpenWindow(#screen,0,0,640,480,"Screen",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#screen),0,0,640,480,1,0,0)
CreateSprite(#sprite,256,256)
If StartDrawing(SpriteOutput(#sprite))
Box(0,0,256,256,$0000FF)
StopDrawing()
EndIf
Repeat
ClearScreen($FF0000)
DisplaySprite(#sprite,50,50) ;red displayed - OK
FlipBuffers()
Until WaitWindowEvent(1)=#PB_Event_CloseWindow
CloseWindow(#screen)
EndIf
If OpenWindow(#screen,0,0,640,480,"Screen",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#screen),0,0,640,480,1,0,0)
CreateSprite(#sprite,256,256,#PB_Sprite_AlphaBlending)
If StartDrawing(SpriteOutput(#sprite))
Box(0,0,256,256,$0000FF)
StopDrawing()
EndIf
Repeat
ClearScreen($FF0000)
DisplaySprite(#sprite,50,50) ;black displayed - ERR
FlipBuffers()
Until WaitWindowEvent(1)=#PB_Event_CloseWindow
CloseWindow(#screen)
EndIf
If OpenWindow(#screen,0,0,640,480,"Screen",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#screen),0,0,640,480,1,0,0)
LoadSprite(#sprite,"box.bmp",#PB_Sprite_AlphaBlending)
If StartDrawing(SpriteOutput(#sprite))
Box(0,0,256,256,$0000FF)
StopDrawing()
EndIf
Repeat
ClearScreen($FF0000)
DisplaySprite(#sprite,50,50) ;red displayed - OK
FlipBuffers()
Until WaitWindowEvent(1)=#PB_Event_CloseWindow
CloseWindow(#screen)
EndIf
First window which uses CreateSprite() without flags allows the red box to be drawn on the sprite and displays as expected.
Second window which uses CreateSprite() with #PB_Sprite_AlphaBlending flag, drawing a red box on the sprite does not work and the box displays as empty.
Third window which loads a black 256x256 image using LoadSprite() with #PB_Sprite_AlphaBlending flag allows the red box to be drawn on the sprite and displays as expected.
If the Subsystem is set to DirectX11, all windows display as expected...