Ramzes Posted September 16, 2011 Posted September 16, 2011 (edited) Hi,I want to create the fastest 2D sprites UDF for AutoIt but I need your help.The best known me library is ProSpeed.dll but there are lots of bugs and we don't need additional library. We've to know how it works and make the same better. Here is a list of ProSpeed functions:expandcollapse popupAddWindowStyle AlphaTrans Antialiasing AttachSprite AttachSpriteAnim BitBltArray BlackWhite Blur BringSpriteToBottom BringSpriteToTop ChangeBytesToWords ChangeDisplay ChangeLongSequence ChangeSpritePara ChangeWordsToLongs CleanUp ClearWith CloneFX Collide CollideAll CollideMore CollideUnknown Collision ColorFill ColorFillImage ColorMove CompareBytes Compute CopyFX CopyMemory CopyMemoryFromBack CopySprite CountAllSprites CountBytes CountFirstBytes CountJoystickButtons CountLongs CountSprites CountStrings CountWords CreateExtFX CreateImage Crypt Curve Darken DataBytes DataMem DataPos DeInitPixelEffects DeleteAllSprites DeleteAllXSprites DeleteAllYSprites DeleteSprite DeleteSpritesIfAnimReady DeleteSpritesMark DeleteTags DePack DownloadHttpFile DSoundDeInit DSoundGetInterfaces DSoundGetNextBuffer DSoundGetStatus DSoundInit DSoundLoad DSoundLoadMemory DSoundLoadResource DSoundPlay DSoundSetGlobalPan DSoundSetGlobalVolume DSoundSetPan DSoundSetVolume DSoundStop DSoundUnLoad Examine ExchangeColor ExchangeRgb ExistSprite ExportPng FindBytes FindBytesCount FindJoystick FindPath FlipX FlipY Fog Frame FreeAllImages FreeFX FreeImage FreePng FXToPng GenerateChecksum GetAByte GetBackgroundInfos GetHeightImage GetInfosImage GetMemHandle GetOriginalSize GetSpriteAnimModeStatus GetSpriteFixMode GetSpriteInfos GetSpriteLayer GetSpriteMark GetSpriteMoveX GetSpriteMoveXY GetSpriteMoveY GetSpritesFps GetSpriteX GetSpriteY GetSystemKey GetVersion GetWidthImage Grey HasSpriteArrived ImportPng InitFX InitPixelEffects InitSprite InitSprite5 InitSpriteBackground InvertChannelPng IsInternet JoystickButton JoystickR JoystickU JoystickV JoystickX JoystickY JoystickZ Lighten LoadFileImage LoadMemoryImage LoadResourceImage LongToAddrVar4 MarkSprite Merge MergeChannelPng MergeImagePng MouseButton MouseOverSprite MoveSprite MoveSpriteWithTable NoStars OemBytes OptionStars Pack PaintImage PaintPng PixelToMemory PMouse PngToFX PSRegister Random ReadFileFast ReadFilePieceFast ReadWatch Replace ReplaceTabs Rotate Rotate180 RotateImage RotateMem Rustle SaveFX SaveImage SaveToMemoryFX SemiTrans SetAByte SetBackAutoCollision SetBytes SetCollideUnknownSprite SetLongs SetMouseRect SetMouseXY SetPixelEffect SetSpriteAnim SetSpriteAnimMode SetSpriteAnimMove SetSpriteCage SetSpriteFixMode SetSpriteLayer SetSpriteMovingMode SetSpritePos SetSpriteSpeed SetTiles SetTiles5 SetWords Sharpen SizeImage SlowDownSprite Smooth SmoothPath SpriteMovingRect SpriteScrollMode SpriteTableMode SpriteThreadBrake SpriteToHDC Stars StartWatch StatusStars StopAllSprites SubWindowStyle SwapSpriteLayers SwitchTaskbar SystemThreadBrake TestSprite Tooltip VarToLong10 VarToLong4 Version VisualTableFix WaitWatch Water WriteFileFastProSpeed imports:GDI32.DLL:BitBlt CreateBitmap CreateCompatibleBitmap CreateCompatibleDC CreateDIBSection CreateDIBitmap CreatePen CreateSolidBrush DeleteDC DeleteObject GdiFlush GetDIBits GetDeviceCaps GetPixel LineTo MoveToEx PolyBezier SelectObject SetBkColor SetDIBitsToDevice SetPixel SetStretchBltMode StretchBltUSER32.DLL:ChangeDisplaySettingsA ClipCursor CreateWindowExA EnumDisplaySettingsA FillRect FindWindowA GetActiveWindow GetAsyncKeyState GetCursorPos GetDC GetKeyState GetWindowLongA LoadBitmapA MessageBoxA PtInRect ReleaseDC ScreenToClient SendMessageA SetCursorPos SetWindowLongA SetWindowPos ShowWindowKERNEL32.DLLDSOUND.DLLOLE32.DLLOLEAUT32.DLLCOMCTL32.DLLWININET.DLLURLMON.DLL To display sprite we must call "InitSprite". But what does this function call in GDI32 or other MS libraries? I don't know. ProSpeed is in attachment. If someone can help me with making this UDF - please post. /RamzesProSpeed.dll Edited September 21, 2011 by Ramzes Sorry for my bad English but nobody is perfect. [font=arial, helvetica, sans-serif]Ramzes[/font]
taietel Posted September 16, 2011 Posted September 16, 2011 Ramzes, a starting point. Things you should know first...In the beginning there was only ONE! And zero... Progs: Reveal hidden contents Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text
Ramzes Posted September 16, 2011 Author Posted September 16, 2011 (edited) ProSpeed uses DIB functions: CreateDIBitmapCreates a device-dependent bitmap (DDB) from a DIB. CreateDIBSectionCreates a DIB that applications can write to directly. GetDIBitsCopies a bitmap into a buffer. SetDIBitsToDeviceSets the pixels in a rectangle using color data from a DIB. Now we need to know how use these functions. My code:#include <WinAPI.au3> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) HotKeySet("{ESC}", "Quit") Global Const $Width = 1200, $Height = 800, $Size = $Width * $Height $hWnd = _WinAPI_CreateWindowEx(0, "AutoIt v3 GUI", "Test", 0, 0, 0, $Width, $Height, 0) WinSetState($hWnd, "", @SW_SHOW) $hDC = _WinAPI_GetDC($hWnd) ConsoleWrite("hDC: " & $hDC & @CR) ; Please draw random image in Paint and save as "1.bmp" $hBitmap = _WinAPI_LoadImage(0, "1.bmp", $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE) ConsoleWrite("hBitmap: " & $hBitmap & @CR) $hdCMem = _WinAPI_CreateCompatibleDC($hDC) $hCmpBitmap = _WinAPI_CreateCompatibleBitmap($hDC, 32, 32) ConsoleWrite("hCmpBitmap: " & $hBitmap & @CR) _WinAPI_SelectObject($hdCMem, $hCmpBitmap) Global $tBits = DllStructCreate("int[" & 1024 & "]") Global $pBits = DllStructGetPtr($tBits) $tBitmap = DllStructCreate("long bmType; long bmWidth; long bmHeight; long bmWidthBytes; ushort bmPlanes; ushort bmBitsPixel; ptr bmBits;") $pBitmap = DllStructGetPtr($tBitmap) $Return = _WinAPI_GetDIBits($hDC, $hCmpBitmap, 5, 32, $pBits, $pBitmap, 0) ConsoleWrite("Return: " & $Return & @CR) While 1 Sleep(10) WEnd Func Quit() Exit EndFunc I need little help with BITMAPINFO. Edited September 16, 2011 by Ramzes Sorry for my bad English but nobody is perfect. [font=arial, helvetica, sans-serif]Ramzes[/font]
taietel Posted September 16, 2011 Posted September 16, 2011 All the info you need regarding the above functions are in Yashied's Sorry for the delay... had to sleep. Things you should know first...In the beginning there was only ONE! And zero... Progs: Reveal hidden contents Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text
monoscout999 Posted September 16, 2011 Posted September 16, 2011 (edited) @Ramzes you are not disposing any element in your example... and i don´t know why you use _Winapi_CreateWindowEx() instead of a regular GUI. I dont know what you mean with fastest 2d Sprites.. fastest compared with what(?) BTW this is a good idea... I was thinking doing some Sprites Manangment UDF(but using GDIPLUS.DLL) by myself a while ago. Edited September 16, 2011 by monoscout999
Ramzes Posted September 17, 2011 Author Posted September 17, 2011 (edited) @taietel This UDF is good but only 336 of 728 functions have examples (I've bad luck because only CreateDIBSection has example...). @monoscout999 GUICreate() is almost the same _Winapi_CreateWindowEx() . I want to create ProSpeed UDF without DLL so it will faster. @smashly It's good but ProSpeed uses only GDI32 so GDIPlus is unnecessary. Now I try to use SetDIBitsToDevice. My code (some functions are from ): Global Const $Width = 32, $Height = 32 $tBIHDR = DllStructCreate($tagBITMAPINFOHEADER) DllStructSetData($tBIHDR, 'biSize', DllStructGetSize($tBIHDR)) DllStructSetData($tBIHDR, 'biWidth', $Width) DllStructSetData($tBIHDR, 'biHeight', $Height) DllStructSetData($tBIHDR, 'biPlanes', 1) DllStructSetData($tBIHDR, 'biBitCount', 32) DllStructSetData($tBIHDR, 'biCompression', $BI_RGB) $hBitmap = _WinAPI_CreateDIBSection(0, $tBIHDR, $DIB_RGB_COLORS, $pBits) $tBITMAPINFO = DllStructCreate($tagBITMAPINFO) $tBits = DllStructCreate("int[" & $Width * $Height & "]") _WinAPI_SetDIBitsToDevice($hDC, 0, 0, 32, 32, $Width, $Height, 0, 32, DllStructGetPtr($tBITMAPINFO)), $DIB_RGB_COLORS, DllCallbackGetPtr($tBits)) If someone know how to use this function please tell me. Edited September 17, 2011 by Ramzes Sorry for my bad English but nobody is perfect. [font=arial, helvetica, sans-serif]Ramzes[/font]
monoscout999 Posted September 18, 2011 Posted September 18, 2011 _Winapi_windowcreateex can not support AutoIt GUI functions like GuiGetMsg(), and i have my doubts about that a no DLL version will be more faster thatn a DLL.. but dont listen to me, a more experienced coder can give you a hint about this... and i find this a nice proyect to do it by your self in pure autoit.
Shanheavel Posted September 19, 2011 Posted September 19, 2011 (edited) Maybe better use OpenGL or DIrectDraw? Btw. free bump! Edited September 19, 2011 by Shanheavel
Ramzes Posted September 20, 2011 Author Posted September 20, 2011 @Shanheavel But I need do it with GDI32. BUMP! Still I'm trying to use SetDIBitsToDevice. Sorry for my bad English but nobody is perfect. [font=arial, helvetica, sans-serif]Ramzes[/font]
Ascend4nt Posted September 20, 2011 Posted September 20, 2011 (edited) You can create a compatible DC, compatible Bitmap, select the Bitmap into the DC, then use SetDIBits (rather than SetDIBitsDevice). Alternatively, if you want to write directly to a given DC's DDB, just use StretchDIBits. I've done some messing around in graphics lately, and there's a number of neat ways to Blit graphics to screen, including Rotation, semi-3D effects, and a Blit with transparency (AlphaBlend) - all done without touching GDI+. If you don't like sprites looking terribly aliased however, GDI+ is the way to go - plus you get an alpha channel with most op's. There's a performance hit for the extra GDI+ effects, but I've not yet compared it for myself. (antialiasing and alpha blending require reading pixels from the destination - assuming GDI+ doesn't get hardware acceleration, that is) I've also done work with DirectDraw (utilizing AutoItObject), which is pretty fun, but has limited usefulness just as GDI32 does. DirectDraw gets you hardware acceleration and allows transparent colors, but you suffer again with aliasing and a lack of an alpha channel. However - you can at least use it to synchronize blits to the vertical refresh. But that's old school now - Direct3D with 'textured quads', or Direct2D (WinVista+) are the way to go for 2D with the benefits of aliasing + alpha channel and other transforms (all hardware accelerated). The reason for my own interest in this area is porting an old side-scroll game demo I created back in the 90's to Windows.. ahh, memories.. *edit: A better article on textured quads: GameDev.net -- 2D in Direct3D using Textured Quads (archive.org) Edited September 20, 2011 by Ascend4nt My contributions: Reveal hidden contents Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
Ramzes Posted September 21, 2011 Author Posted September 21, 2011 (edited) @Ascend4nt Thank you.Your post is very useful for me. I'll test speed of DirectDraw and Direct3D. Maybe after I'll create 2D sprites UDF using one of them or GDI32. Please close this topic. Edited September 21, 2011 by Ramzes Sorry for my bad English but nobody is perfect. [font=arial, helvetica, sans-serif]Ramzes[/font]
Enforcer Posted September 26, 2011 Posted September 26, 2011 (edited) I used ProSpeed and tryed to create my own Map Editor for a small game...I didn't finished my editor cose many bugs that I can't solve... My unfinished map-editor example (using prospeed): http://nfk.pro2d.ru/files/MAP-EDITOR-AU3.rarTo test just run TEEEEESTTT-----Trx-Designer.au3 then open map from folder REAL-MAPSThen you can add eny sprite (BMP) only (!?)... And without eny transparency (!?)... Also everything is blinking ;D I hope this unfinished example will help to someone...Sorry for my english... Edited September 26, 2011 by Enforcer [RU] Zone
Ramzes Posted September 26, 2011 Author Posted September 26, 2011 (edited) @Enforcer I've download and check it. It's not bad (but you have a mess in your code). Answering your questions about ProSpeed:Sometimes ago I was creating little MMORPG with this library. You can use BMP, PNG, GIF... with transparency and it isn't blinking. But you must use sprite functions to do it. Here is little example of using sprites (you need ProSpeed.au3): Global Const $HDC = GetHDC() Background("", 0, 0, 200, 100) $LoadSprite = LoadSprite(@ScriptDir & "\sprite1.png") $LoadSpriteResize = LoadSpriteResize(@ScriptDir & "\sprite1.png", 256, 128) Sprite($LoadSprite, $HDC, 0, 0, 32, 32, 1, 1, 0, 0, 0) But it isn't good way to making game. Now I'm writing my own graphical library. Edited September 26, 2011 by Ramzes Sorry for my bad English but nobody is perfect. [font=arial, helvetica, sans-serif]Ramzes[/font]
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now