Hi,
wenn ich das GDI+ Programm auf meiner Kiste mit nVidia 8800GT laufen lasse, dann ist die Performance so schlecht, dass man die Pixel einzeln zählen kann.
Kann jemand das auch bestätigen?
Meine Kiste:
WinXP Pro SP3
Intel Core Duo @ 2.5 GHz
nVidia 8800GT (neueste Treiber! War auch genauso mit Älteren)
Mit einigen anderen GDI+ Codes, wie z.B. AUTOITEROIDS, und auf meinen 2 Notebooks gibt es keine Probleme!
Hier der Code:
Spoiler anzeigen
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/so
#AutoIt3Wrapper_Res_SaveSource=n
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Run_After=upx.exe --best "%out%"
#AutoIt3Wrapper_Run_After=del /f /q "Explosions (from AutoIteroids)_Obfuscated.au3"
#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <Array.au3>
Opt('MustDeclareVars', 1)
Global $hGUI, $hWnd, $hGraphic, $width, $height
$width = @DesktopWidth * 0.75
$height = @DesktopHeight * 0.75
Global Const $explosion_step = 6, $explosion_length = ($width + $height) / 8, $explosion_max_amount = 20, $explosion_max_particle = 20
Global $explosion_coordinate[$explosion_max_particle][6 * $explosion_max_amount] ; on/off, x, y, vx, vy, v
Global $explosion_amount = 0
; Create GUI
$hGUI = GUICreate("Explosions (from AUTOITEROIDS) using GDI+ by UEZ 2009!", $width, $height)
$hWnd = WinGetHandle($hGUI)
_GDIPlus_Startup()
Global $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
Global $bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)
Global $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
_GDIPlus_GraphicsClear($backbuffer)
_GDIPlus_GraphicsSetSmoothingMode($backbuffer, 4)
Global $pen_size = 1
Global $pen_color = 0xAFFF8070
Global $pen = _GDIPlus_PenCreate($pen_color, $pen_size)
GUISetState()
Do
_GDIPlus_GraphicsClear($backbuffer, 0x9A000000)
If Mod(Random(1, 10, 1), 9) >= 5 Then ;
Explosion_Init(Random(50, $width - 50, 1), Random(50, $height - 50, 1))
EndIf
Explosion()
_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)
Until Not Sleep(30) Or GUIGetMsg() = $GUI_EVENT_CLOSE
; Clean up resources
_GDIPlus_PenDispose($pen)
_GDIPlus_BitmapDispose($bitmap)
_GDIPlus_GraphicsDispose($graphics)
_GDIPlus_GraphicsDispose($backbuffer)
_GDIPlus_Shutdown()
Func Explosion_Init($ex, $ey) ;initialise explosion
For $o = 0 To $explosion_step * ($explosion_max_amount - 1) Step $explosion_step ;fill array with coordinate of hit object
If $explosion_coordinate[0][$o] <> 1 Then
$explosion_coordinate[0][$o] = 1
$explosion_coordinate[0][$o + 1] = $ex ;save x coordinate
$explosion_coordinate[0][$o + 2] = $ey ;save x coordinate
For $n = 0 To $explosion_max_particle - 1
$explosion_coordinate[$n][$o + 1] = $explosion_coordinate[0][$o + 1] ;duplicate x start position of all explosion particles
$explosion_coordinate[$n][$o + 2] = $explosion_coordinate[0][$o + 2] ;duplicate y start position of all explosion particles
$explosion_coordinate[$n][$o + 3] = _Random(-7, 7, 1) ;create random x vector (explosion particle speed)
$explosion_coordinate[$n][$o + 4] = _Random(-7, 7, 1) ;create random y vector (explosion particle speed)
$explosion_coordinate[$n][$o + 5] = Abs($explosion_coordinate[$n][3 + $o]) + Abs($explosion_coordinate[$n][4 + $o]) ;add absolute distance of vectors x and y
Next
ExitLoop
EndIf
Next
EndFunc ;==>Explosion_Init
Func Explosion() ;draw explosions coordinates
Local $q, $k
$explosion_amount = 0
For $k = 0 To $explosion_step * ($explosion_max_amount - 1) Step $explosion_step
If $explosion_coordinate[0][$k] = 1 Then ;only draw active explosions
$explosion_amount += 1
For $q = 0 To $explosion_max_particle - 1
$explosion_coordinate[$q][$k + 1] += $explosion_coordinate[$q][$k + 3] ;draw new x coordinate of a particle
$explosion_coordinate[$q][$k + 2] += $explosion_coordinate[$q][$k + 4] ;draw new y coordinate of a particle
$explosion_coordinate[$q][$k + 5] += Abs($explosion_coordinate[$q][$k + 3]) + Abs($explosion_coordinate[$q][$k + 4])
If $explosion_coordinate[$q][$k + 5] <= $explosion_length Then ;draw until max. distance has been reached
_GDIPlus_GraphicsDrawEllipse($backbuffer, $explosion_coordinate[$q][$k + 1], $explosion_coordinate[$q][$k + 2], 2, 2, $pen)
Else ;when max. distance has been reached then set x vector and y vector to 0
$explosion_coordinate[0][$k] = 0
EndIf
Next
EndIf
Next
ConsoleWrite($explosion_amount & @CRLF)
EndFunc ;==>Explosion
Func _Random($w1, $w2, $w3 = 0) ;just to avoid 0 as random number
Local $x = 0, $l1 = 0.50
While $x = 0
$x = Random($w1, $w2, $w3)
If $x < $l1 And $x >= 0 Then $x += $l1
If $x > -$l1 And $x <= 0 Then $x -= $l1
WEnd
Return $x
EndFunc ;==>_Random
Kann sich jemand vorstellen, warum das so ist?
Gruß,
UEZ
PS: wie kann ich die Anzahl der Downloads von Anhängen (s.o.) darstellen?