Je me demande entre le canvas, la fenêtre, le screen et le screen fenêtré lequel est le plus rapide pour y dessiner ?
J'ai fait ce code, mais comme vous allez le constater, l'affichage du dégradé derriére le Sherman est trés saccadé.
Les fichiers se trouvent ici(code + Sherman + BASS)
Code : Tout sélectionner
IncludeFile "bass.pbi"
IncludeFile "bass2.pbi"
UsePNGImageDecoder()
Enumeration
#Sherman
#Fond
#Window
EndEnumeration
Define File.s
Global streamID, width,height, ShermanX,ShermanY, FPScount,FPS
#width = 800
#height = 600
Declare TH_Background(param)
If CountProgramParameters() = 0
File = OpenFileRequester("Choisissez un fichier à lire","","Musique|*.wav;*.mp3;*.ogg|Wave|*.wav|MP3|*.mp3",0)
Else
File = ProgramParameter(0)
EndIf
LoadImage(#Sherman,"M4_Sherman_early_normandy.png")
ShermanX = (#width/2)-(ImageWidth(#Sherman)/2)
ShermanY = (#height/2)-(ImageHeight(#Sherman)/2)
OpenWindow(#Window, 0, 0, #width,#height,"Sherman - ",#PB_Window_ScreenCentered | #PB_Window_SystemMenu)
CanvasGadget(#Fond,0,0,#width,#height)
AddWindowTimer(#Window,1,1000)
retval_init = BASS_Init(-1,48000,0,WindowID(#Window),0)
streamID = BASS_StreamCreateFile(#False,File,0,0,#BASS_UNICODE | #BASS_SAMPLE_FLOAT | #BASS_SAMPLE_LOOP)
BASS_ChannelPlay(streamID,0)
CreateThread(@TH_Background(),1)
;- Boucle principale
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_Timer
If EventTimer()= 1
FPS = FPScount
FPScount= 0
EndIf
EndSelect
Until event = #PB_Event_CloseWindow
;-Procédures
Procedure TH_Background(param)
Protected vol,volf.f,clr.i
Repeat
vol = BASS_ChannelGetLevel(streamID)
vol = (vol & $FFFF)
volf = (vol/32768)*255
If clr = $FFFFFF
clr = 0
Else
clr = $FFFFFF
EndIf
FPScount + 1
StartDrawing(CanvasOutput(#Fond))
Box(0,0,#width,#height,$000000)
FrontColor($000000)
BackColor(RGB(volf,volf,volf))
DrawingMode(#PB_2DDrawing_Gradient)
CircularGradient(#width/2,#height/2,500)
Box(0,0,#width,#height,RGB(volf,volf,volf))
DrawingMode(#PB_2DDrawing_Default)
Box(0,0,10,10,clr)
DrawText(11,0,Str(FPS))
DrawingMode(#PB_2DDrawing_AlphaBlend)
DrawImage(ImageID(#Sherman),ShermanX, ShermanY)
StopDrawing()
Debug clr
Delay(25)
ForEver
EndProcedure