Page 1 of 1

SpriteBlendingMode default error

Posted: Tue Jan 16, 2024 12:33 pm
by SPH
Source and destination modes can take any of the following values:
-#PB_Sprite_BlendZero
-#PB_Sprite_BlendOne
-#PB_Sprite_BlendSourceColor
-#PB_Sprite_BlendInvertSourceColor
-#PB_Sprite_BlendDestinationColor
-#PB_Sprite_BlendInvertDestinationColor
-#PB_Sprite_BlendSourceAlpha
-#PB_Sprite_BlendInvertSourceAlpha
-#PB_Sprite_BlendDestinationAlpha
-#PB_Sprite_BlendInvertDestinationAlpha

The default values are SpriteBlendingMode(#PB_Sprite_BlendSourceAlpha, #PB_Sprite_BlendInvertSourceAlpha)

Code: Select all

; Initialisation du monde 2D
InitSprite()
InitKeyboard()
InitMouse()

; Ouverture de la fenêtre
OpenWindow(0,0,0,1024,768,"Souris - MouseDeltaX",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0),0,0,1024,768,1,0,0)

CreateSprite(0,50,50);,#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(0))
LineXY(0,0,50,25,RGB(255,80,80))
LineXY(0,0,25,50,RGB(255,80,80))
LineXY(25,50,50,25,RGB(255,80,80))
StopDrawing()

CreateSprite(1,100,100);,#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(1))
Circle(50,50,49,RGB(255,255,0))
Circle(50,50,40,RGB(0,255,0))
Circle(50,50,30,RGB(0,255,255))
Circle(50,50,20,RGB(0,0,255))
Circle(50,50,10,RGB(255,0,0))
StopDrawing()


; Gestion de la fenêtre et de l'écran
Repeat
  Repeat : Event  = WindowEvent() : Until Event = 0
  
  ExamineMouse() ; Etat de la souris
  xm=MouseX()
  ym=MouseY()
  
  If MouseButton(#PB_MouseButton_Left)
    SpriteBlendingMode(#PB_Sprite_BlendSourceAlpha, #PB_Sprite_BlendInvertSourceAlpha)
  EndIf
  
  For u=0 To 7
    For i=0 To 10
      DisplaySprite(1,i*100,u*100)
    Next
  Next
  
  ; Affichage de l'état des boutons de la souris
  StartDrawing(ScreenOutput())
  
  DrawText(250,230, "MouseX " + Str(xm), RGB(255,255,255))
  DrawText(250,260, "MouseY " + Str(ym), RGB(255,255,255))
  DrawText(250,388, "MouseButton(left) : SpriteBlendingMode default", RGB(255,255,10))
  
  StopDrawing()
  DisplayTransparentSprite(0,xm,ym)
  
  FlipBuffers()
  ClearScreen(RGB(0,0,0)) 
  
  ExamineKeyboard()
Until KeyboardPushed(#PB_Key_All)
End
The doc says that the default values of "SpriteBlendingMode"
it is: SpriteBlendingMode(#PB_Sprite_BlendSourceAlpha, #PB_Sprite_BlendInvertSourceAlpha)

When you left mouse click, it makes the mouse non-transparent!
For what ?

thx

Re: SpriteBlendingMode default error

Posted: Tue Jan 16, 2024 2:42 pm
by ChrisR
It looks good, if you use DirectX9 subsystem in compiler options,
Since PB 6.0, the default Windows subsystem has switched from DirectX9 to OpenGL.

With OpenGL subsystem, indeed, the mouse loses its transparency with SpriteBlendingMode(#PB_Sprite_BlendSourceAlpha, #PB_Sprite_BlendInvertSourceAlpha) default values!
Without SpriteBlendingMode(DefaultValues), it looks better and we don't get the same result.
So unlike the help, the default values are not the same with OpenGL.

#
Also, I noted that some constants are missing for SpriteBlendingMode AutoComplete context sensitive mode:

In ConstantsData.pbi

Code: Select all

Data$ "SpriteBlendingMode,1,#PB_Sprite_BlendZero,#PB_Sprite_BlendInvertSourceColor,#PB_Sprite_BlendInvertDestinationColor,#PB_Sprite_BlendInvertSourceAlpha,#PB_Sprite_BlendInvertDestinationAlpha"
Data$ "SpriteBlendingMode,2,#PB_Sprite_BlendZero,#PB_Sprite_BlendInvertSourceColor,#PB_Sprite_BlendInvertDestinationColor,#PB_Sprite_BlendInvertSourceAlpha,#PB_Sprite_BlendInvertDestinationAlpha"
=> Should be

Code: Select all

Data$ "SpriteBlendingMode,1,#PB_Sprite_BlendZero,#PB_Sprite_BlendOne,#PB_Sprite_BlendSourceColor,#PB_Sprite_BlendInvertSourceColor,#PB_Sprite_BlendDestinationColor,#PB_Sprite_BlendInvertDestinationColor,#PB_Sprite_BlendSourceAlpha,#PB_Sprite_BlendInvertSourceAlpha,#PB_Sprite_BlendDestinationAlpha,#PB_Sprite_BlendInvertDestinationAlpha"
Data$ "SpriteBlendingMode,2,#PB_Sprite_BlendZero,#PB_Sprite_BlendOne,#PB_Sprite_BlendSourceColor,#PB_Sprite_BlendInvertSourceColor,#PB_Sprite_BlendDestinationColor,#PB_Sprite_BlendInvertDestinationColor,#PB_Sprite_BlendSourceAlpha,#PB_Sprite_BlendInvertSourceAlpha,#PB_Sprite_BlendDestinationAlpha,#PB_Sprite_BlendInvertDestinationAlpha"
Edit: I've added a pull Request #258