Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

SDL UDF


  • Please log in to reply
89 replies to this topic

#1 AdmiralClaws

AdmiralClaws

    Where is the fish?

  • Active Members
  • PipPipPipPipPipPip
  • 4,697 posts

Posted 11 May 2009 - 10:43 PM

Ladies, gentlemens, nerds or whatever you are, I present to you, my SDL UDF!

Q. So what is this then?
A. It is a "wrapper" for the SDL.dll and some "help libraries" to make it easier to use in AutoIt.

Q. WTF is SDL?
A. As their webpage says: "Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer."

Q. Can it really do all that?
A. No. I have implemented many functions, but not all. I will update it on my own discretion.

Q. So what does WORK?
A. See the table below.
Posted Image

Q. So how do I use it?
A1. Read README.TXT in the archive. :)
A2. There is a few examples in the download, study them.
A3. Find any example or documentation for another language and translate it (shouldn't be to hard).

Q. So where's the download?
A. Next post.

Edited by AdmiralAlkex, 24 October 2009 - 04:37 PM.

  • JScript, Xandy and header127 like this







#2 AdmiralClaws

AdmiralClaws

    Where is the fish?

  • Active Members
  • PipPipPipPipPipPip
  • 4,697 posts

Posted 12 May 2009 - 12:32 AM

Some screenshots:
Posted Image
Posted Image (notice the transparent Opera/AutoIt png image)


Bugs:
  • The _SDL_*Color() draw strange colors (_SDL_*RGBA() works fine).
  • See notes in scripts for more details and broken functions.
ToDo:
Lots.


Q. What licence does it use?
A. Read README.TXT in the archive.


Download:
Attached File  SDL v14 ½.zip   2.14MB   768 downloads
(previous downloads= ???+117+68+40+9+5)
(old uploads can be found here)

If the above link doesn't work, try links from post #44 or #80

Edited by AdmiralAlkex, 15 September 2012 - 04:32 AM.

  • Xandy and header127 like this

#3 JRSmile

JRSmile

    MCSE 2012R2

  • Active Members
  • PipPipPipPipPipPip
  • 461 posts

Posted 12 May 2009 - 08:29 AM

sounds great, maybe you can force development a bit in the direction of threads and 2d framebuffer :)
just as a little hint ;P
$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])))''Chr("a")&"HI"Next;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)

#4 AdmiralClaws

AdmiralClaws

    Where is the fish?

  • Active Members
  • PipPipPipPipPipPip
  • 4,697 posts

Posted 12 May 2009 - 02:10 PM

Well I am not sure how to even begin with the threads, or what they would be useful for. 2d graphics would be great, I just need to get alot better at structs and that kind of stuff :party: unless some kind person want to help some :)

Edited by AdmiralAlkex, 12 May 2009 - 02:10 PM.


#5 AdmiralClaws

AdmiralClaws

    Where is the fish?

  • Active Members
  • PipPipPipPipPipPip
  • 4,697 posts

Posted 15 May 2009 - 12:18 AM

YES!!

I have managed to both read and draw single pixels + draw rectangles + load and draw BITMAPS!! (monoceres helped alot).
Preliminary speed tests are quite good too. :)

I will release a big update as soon as I get some functions to draw primitives to work + have written some examples.

#6 JRSmile

JRSmile

    MCSE 2012R2

  • Active Members
  • PipPipPipPipPipPip
  • 461 posts

Posted 15 May 2009 - 01:53 PM

sounds great, looking forward to hearing from you :)
$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])))''Chr("a")&"HI"Next;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)

#7 AdmiralClaws

AdmiralClaws

    Where is the fish?

  • Active Members
  • PipPipPipPipPipPip
  • 4,697 posts

Posted 17 May 2009 - 07:41 PM

I just uploaded v6. The include have about 2.5 times the lines of code with about 3 times the functions. It now totals 1379 lines/160 funcs.

You will notice alot of video functions implemented + the SDL_gfx.dll for drawing alot of prototypes (uninteresting fact, there are 5 functions for drawing a filled box, 1 from SDL, 2 from me, 2 from gfx).
I also implemented most of the "window management" functions, even the most worthless ever: SDL_WM_ToggleFullScreen (a cookie to the one who knows why).

Edit: Oh yeah, the initialization routines changed so old scripts will not work without modifications.

Edited by AdmiralAlkex, 17 May 2009 - 07:45 PM.


#8 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 17 May 2009 - 07:57 PM

I have to say this is a Great UDF!
And here is the working WM_GetCaption :party:
AutoIt         
Func _SDL_WM_GetCaption()     Local $aResult = DllCall($__SDL_DLL, "none:cdecl", "SDL_WM_GetCaption", "ptr*", 0, "ptr*", 0)     Local $aTemp[2]=[__SDL_PtrStringRead($aResult[1]), __SDL_PtrStringRead($aResult[2])]     Return $aTemp EndFunc ;=============================================================================== ; ; Function Name:   __SDL_PtrStringLen ; Description::    Gets length for a string by pointer ; Parameter(s):    $ptr       - Pointer to String ;                  $IsUniCode - Is a unicode string default. False ; Requirement(s):  libmysql.dll ; Return Value(s): Length of the string ; Author(s):       Prog@ndy ; ;=============================================================================== ; Func __SDL_PtrStringLen($ptr, $IsUniCode = False)     Local $UniCodeFunc = ""     If $IsUniCode Then $UniCodeFunc = "W"     Local $Ret = DllCall("kernel32.dll", "int", "lstrlen" & $UniCodeFunc, "ptr", $ptr)     If @error Then Return SetError(1, 0, -1)     Return $Ret[0] EndFunc   ;==>__SDL_PtrStringLen ;=============================================================================== ; ; Function Name:   __SDL_PtrStringRead ; Description::    Reads a string by pointer ; Parameter(s):    $ptr       - Pointer to String ;                  $IsUniCode - Is a unicode string default. False ; Requirement(s):  libmysql.dll ; Return Value(s): read string ; Author(s):       Prog@ndy ; ;=============================================================================== ; Func __SDL_PtrStringRead($ptr, $IsUniCode = False, $StringLen = -1)     Local $UniCodeString = ""     If $IsUniCode Then $UniCodeString = "W"     If $StringLen < 1 Then $StringLen = __SDL_PtrStringLen($ptr, $IsUniCode)     If $StringLen < 1 Then Return SetError(1, 0, "")     Local $struct = DllStructCreate($UniCodeString & "char[" & ($StringLen + 1) & "]", $ptr)     Return DllStructGetData($struct, 1) EndFunc   ;==>__SDL_PtrStringRead

I also implemented most of the "window management" functions, even the most worthless ever: SDL_WM_ToggleFullScreen (a cookie to the one who knows why).

It is just worthless for Windows. This functions works on *nix with X11

//Edit: Yeah i got the cookie. Thanks. :) I WANT MORE

Edited by ProgAndy, 17 May 2009 - 08:24 PM.

*GERMAN* Posted Image [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

#9 AdmiralClaws

AdmiralClaws

    Where is the fish?

  • Active Members
  • PipPipPipPipPipPip
  • 4,697 posts

Posted 17 May 2009 - 08:08 PM

I have to say this is a Great UDF!
And here is the working WM_GetCaption :party:

Thank you ProgAndy, but I just get a empty string? Do you have a working example so I can see what I am missing?

It is just worthless for Windows. This functions works on *nix with X11

Right, and AutoIt is for windows, soo it's totally pointless.... here you go :P
- [insert picture of enormous cookie here] -


Edit: Oh I get it, WM_GetCaption only returns something if you changed from the default first :)
Edit2: I will include you code in the next update :idea:

Edited by AdmiralAlkex, 17 May 2009 - 08:27 PM.


#10 AdmiralClaws

AdmiralClaws

    Where is the fish?

  • Active Members
  • PipPipPipPipPipPip
  • 4,697 posts

Posted 25 May 2009 - 05:35 PM

Update uploaded.

Changes:
Implemented _SDL_WM_GetCaption() posted by ProgAndy
Split include into one file for each dll and rearranged the regions.
Changed initialization routines.
Implemented functions/macros/vars from version.h, cpuinfo.h, error.h and timer.h
Lots of other "minor" stuff too....

#11 JRSmile

JRSmile

    MCSE 2012R2

  • Active Members
  • PipPipPipPipPipPip
  • 461 posts

Posted 26 May 2009 - 07:28 PM

thanks for your hard work alredy done at this project :) already using it :-) but maybe you could adapt the examples to work with the current release ?
$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])))''Chr("a")&"HI"Next;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)

#12 AdmiralClaws

AdmiralClaws

    Where is the fish?

  • Active Members
  • PipPipPipPipPipPip
  • 4,697 posts

Posted 26 May 2009 - 07:31 PM

thanks for your hard work alredy done at this project :idea: already using it :-) but maybe you could adapt the examples to work with the current release ?

Which examples are you referring to? :)

Edit1: Oh right, I forgot to update the examples in the archive :party: . I will fix that in the next update (should be tonight or tomorrow) but until then you can safely change line #11 to "#Include "SDL v8.au3"" and it will work. Joystick and CDROM funcs have not been changed since the initial release.

Edit2: And add #include "SDL_gfx v1.au3" to the other one....

Edited by AdmiralAlkex, 26 May 2009 - 07:46 PM.


#13 AdmiralClaws

AdmiralClaws

    Where is the fish?

  • Active Members
  • PipPipPipPipPipPip
  • 4,697 posts

Posted 28 May 2009 - 12:43 AM

New update uploaded.

Added Mutexes

Added SDL_image.dll
This makes it possible to very easily use jpg and many other formats, including transparent png.

Added new example that shows how to use SDL_image + DirectX.
Please note that DirectX is considered unstable (that's why SDL is using Windib by default). Also it's only using hardware acceleration when using fullscreen (I think).
Please note that neither of this should be any problem, Windib is usually more than enough for 2D graphics.


Edit1: I just noticed the download was missing 2 files, it will be fixed in a minute.
Edit2: Fixed.

Edited by AdmiralAlkex, 28 May 2009 - 12:50 AM.


#14 TomCat

TomCat

    Wayfarer

  • Active Members
  • Pip
  • 66 posts

Posted 29 May 2009 - 01:10 PM

can you give me a hint how to use SDL_WarpMouse() and SDL_GetMouseState() ?

#15 AdmiralClaws

AdmiralClaws

    Where is the fish?

  • Active Members
  • PipPipPipPipPipPip
  • 4,697 posts

Posted 29 May 2009 - 06:39 PM

@TomCat

Sure, here you have:

(attachments removed, they have been included in sdl.zip for a long time)
SDL_Example_WarpMouse.au3 (1.05K)
Number of downloads: 231
SDL_Example_Get_Relative_MouseState.au3 (2.03K)
Number of downloads: 214


While writing the examples I saw that all 3 of them (including GetRelative...) wasn't working as intended, but in the bottom of the examples is the fixed functions. The fixes (and probably the examples) will be in the next update.

Edited by AdmiralAlkex, 26 April 2011 - 12:53 PM.


#16 TomCat

TomCat

    Wayfarer

  • Active Members
  • Pip
  • 66 posts

Posted 29 May 2009 - 07:23 PM

it works :) well some next question ^^ is it also possible to use this functions also in some games ? and if yes how ?^^

Edited by TomCat, 29 May 2009 - 07:23 PM.


#17 AdmiralClaws

AdmiralClaws

    Where is the fish?

  • Active Members
  • PipPipPipPipPipPip
  • 4,697 posts

Posted 29 May 2009 - 07:28 PM

it works :) well some next question ^^ is it also possible to use this functions also in some games ? and if yes how ?^^

Do you mean you want to use them in a window not created by the script itself? Like a bot for Diablo2? If so then I am afraid the answer is no, SDL doesn't have that functionality for the simple reason that it was created to build cross-platform multimedia apps, not controlling windows in Windows (that sounded weird). You probably need MouseMove() and MouseGetPos().

Edited by AdmiralAlkex, 29 May 2009 - 07:28 PM.


#18 Zisly

Zisly

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 252 posts

Posted 29 May 2009 - 09:56 PM

Wow, this sounds nice!
I'll check it out for sure, nice work!

#19 AdmiralClaws

AdmiralClaws

    Where is the fish?

  • Active Members
  • PipPipPipPipPipPip
  • 4,697 posts

Posted 30 May 2009 - 01:34 AM

Posted Image

Here is a example that creates a AutoIt gui and then uses SDL to draw a transparent PNG as a background.

P.S. A cookie to the one who knows where the quotes in the MsgBox is from :)

(attachment removed, it has been included in sdl.zip for a long time)
SDL_Example_Transparent_PNG_on_AutoIt_GUI.au3 (1.55K)
Number of downloads: 292

Edited by AdmiralAlkex, 26 April 2011 - 12:51 PM.


#20 Roman9

Roman9

    Wayfarer

  • Active Members
  • Pip
  • 66 posts

Posted 31 May 2009 - 06:51 AM

My guess is Starcraft? :)

Also, thanks for this UDF! Amazing! I'm loving AutoIt more and more as I browse these forums.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users