Jump to content

Autoit SDL2 DLL Help


Recommended Posts

You're welcome.

As you can see in my sdl2.au3, the dllopen() is not necessary.  You can just point the dllcall() to the correct dll file.

Link to comment
Share on other sites

Yeah.  Ok I need a little help getting this example to work. I am getting this error  C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\username\Documents\Code\AuotIt\SDLTest2.au3"    
>Exit code: 3221225477

The window appears, but then comes up with the exit code and the windows failed to close this program properly pops up.

Wrapper Script

Global Const $SDL_INIT_TIMER = 1
Global Const $SDL_INIT_AUDIO = 16
Global Const $SDL_INIT_VIDEO = 32
Global Const $SDL_INIT_JOYSTICK = 512
Global Const $SDL_INIT_HAPTIC = 4096
Global Const $SDL_INIT_GAMECONTROLLER = 8192
Global Const $SDL_INIT_EVENTS = 16384
Global Const $SDL_INIT_NOPARACHUTE = 1048576
Global Const $SDL_INIT_EVERYTHING = BitOR($SDL_INIT_TIMER, $SDL_INIT_AUDIO, $SDL_INIT_VIDEO, $SDL_INIT_EVENTS, $SDL_INIT_JOYSTICK, $SDL_INIT_HAPTIC,$SDL_INIT_GAMECONTROLLER)

Global Const $SDL_WINDOW_FULLSCREEN = 1
Global Const $SDL_WINDOW_OPENGL = 2
Global Const $SDL_WINDOW_SHOWN = 4
Global Const $SDL_WINDOW_HIDDEN = 8
Global Const $SDL_WINDOW_BORDERLESS = 16
Global Const $SDL_WINDOW_RESIZABLE = 32
Global Const $SDL_WINDOW_MINIMIZED = 64
Global Const $SDL_WINDOW_MAXIMIZED = 128
Global Const $SDL_WINDOW_INPUT_GRABBED = 256
Global Const $SDL_WINDOW_INPUT_FOCUS = 512
Global Const $SDL_WINDOW_MOUSE_FOCUS = 1024
Global Const $SDL_WINDOW_FULLSCREEN_DESKTOP = BitOR($SDL_WINDOW_FULLSCREEN, 256)
Global Const $SDL_WINDOW_FOREIGN = 2048
Global Const $SDL_WINDOW_HIGHDPI = 8192
Global Const $SDL_WINDOW_ALWAYS_ON_TOP = 32768

Global Const $SDL_WINDOWPOS_CENTERED_MASK = 805240832
Global Const $SDL_WINDOWPOS_CENTERED_DISPLAY = $SDL_WINDOWPOS_CENTERED_MASK
Global Const $SDL_WINDOWPOS_CENTERED = $SDL_WINDOWPOS_CENTERED_DISPLAY
Global Const $SDL_WINDOWPOS_ISCENTERED = $SDL_WINDOWPOS_CENTERED_MASK

Func SDL_Init($flags)
   Local $xSDL_Init = DllCall($SDL,"uint:cdecl","SDL_Init","uint", $flags)
   Return $xSDL_Init[0]
EndFunc

Func SDL_Quit()
   $xSDL_Quit = DllCall($SDL,"none","SDL_Quit")
   Return $xSDL_Quit[0]
EndFunc

Func SDL_CreateWindow($title,$x,$y,$w,$h,$flags)
   Local $xSDL_CreateWindow = DllCall($SDL,"ptr:cdecl","SDL_CreateWindow","str",$title,"int",$x,"int",$y,"int",$w,"int",$h,"uint",$flags)
   Return $xSDL_CreateWindow[0]
EndFunc

Func SDL_DestroyWindow($win)
   $xSDL_DestroyWindow = DllCall($SDL,"none","SDL_DestroyWindow","ptr",$win)
   Return $xSDL_DestroyWindow[0]
EndFunc

Func SDL_Delay($ms)
   Local $xSDL_Delay = DllCall($SDL,"none","SDL_Delay","uint",$ms)
   Return $xSDL_Delay[0]
EndFunc

DllClose($SDL)

Example Script

#include <SDL2.au3>

Local $w = 640, $h = 480

Local $x = SDL_Init($SDL_INIT_VIDEO)

Local $win = SDL_CreateWindow("MyWin",$SDL_WINDOWPOS_CENTERED,$SDL_WINDOWPOS_CENTERED,$w,$h,$SDL_WINDOW_SHOWN)

SDL_Delay(3000)

SDL_DestroyWindow($win)

SDL_Quit()

 

Edited by LeftyGuitar
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...