In my example below I create a sprite and fill it completely green, and then I draw a red circle with a diameter of the box.
The green is set to transparent, and this all works fine. The sprite is displayed as it should be.
When I draw to the sprite a second time just like I did to the first except I make the red circle smaller. The result is a large green circle with a smaller red circle inside it.
The problem seems to be caused by TransparentSpriteColor. If I call TransparentSpriteColor only after the second draw the result is correct and I only see a small red circle. If I call it after each draw then I get the large green and small red circles.
I'm using PB 5.5 (x64) on Windows 7 and have tested it on both DirectX and OpenGL.
Code: Select all
EnableExplicit
If InitSprite() = 0
MessageRequester("Error!", "Failed to init the sprite system.", #PB_MessageRequester_Ok)
End
EndIf
Define.i Event
Define.i WinW = 800
Define.i WinH = 600
If OpenWindow(0, 0, 0, WinW, WinH, "Transparent Sprite Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If OpenWindowedScreen(WindowID(0), 0, 0, WinW, WinH) = 0
MessageRequester("Error!", "Failed to open the screened window.", #PB_MessageRequester_Ok)
End
EndIf
CreateSprite(1, 256, 256, #PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(1))
DrawingMode(#PB_2DDrawing_Default)
Box(0, 0, 256, 256, RGB(0,255,0)) ;Fill the entire sprite with a green background
Circle(128, 128, 128, RGB(255,0,0)) ;Draw a large red circle
StopDrawing()
;####
;Comment out the below TransparentSpriteColor() and everthing works correctly
TransparentSpriteColor(1, RGB(0,255,0))
;####
StartDrawing(SpriteOutput(1))
DrawingMode(#PB_2DDrawing_Default)
Box(0, 0, 256, 256, RGB(0,255,0)) ;Fill the entire sprite with a green background
Circle(128, 128, 64, RGB(255,0,0)) ;Draw a small red circle
StopDrawing()
TransparentSpriteColor(1, RGB(0,255,0))
Repeat
DisplayTransparentSprite(1, 200, 200)
FlipBuffers()
Until WindowEvent() = #PB_Event_CloseWindow
EndIf
End