LeftyGuitar Posted April 30, 2018 Share Posted April 30, 2018 (edited) Hello, My example program keeps crashing after the window appears. It exits with code: >"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\Username\Documents\Code\AuotIt\SDLTest2.au3" >Exit code: 3221225477 Time: 3.182 Wrapper Code expandcollapse popupGlobal 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 Program #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 May 1, 2018 by LeftyGuitar Link to comment Share on other sites More sharing options...
Developers Jos Posted April 30, 2018 Developers Share Posted April 30, 2018 This can't be any runable code as you nowhere define the used DLL and the $SDL! Also it feels pretty strange you do a DLLCLOSE() as the end of the Include file without it being in any Func. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
LeftyGuitar Posted April 30, 2018 Author Share Posted April 30, 2018 expandcollapse popupGlobal 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 ;Open the SDL2 DLL Global $SDL = ("SDL2.dll") 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) Sorry I forgot to add that piece of code in the original post. Still not sure why the example program is crashing. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 30, 2018 Developers Share Posted April 30, 2018 My last statement is still valid! Have you looked at it? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
LeftyGuitar Posted April 30, 2018 Author Share Posted April 30, 2018 Func SDL_Init($flags) $SDL = DllOpen("SDL2.dll") Local $xSDL_Init = DllCall($SDL,"uint:cdecl","SDL_Init","uint", $flags) If @error Then Return SetError(1, @error, -1) Return $xSDL_Init[0] EndFunc Func SDL_Quit() $xSDL_Quit = DllCall($SDL,"none","SDL_Quit") DllClose($SDL) EndFunc I've added these into the wrapper code, but the example program crashes when it attempts to close the window after 3 seconds. It says this AutoIt script has stopped working. Link to comment Share on other sites More sharing options...
Danyfirex Posted May 1, 2018 Share Posted May 1, 2018 Hello. this work for me. just fixed some return type values here. expandcollapse popupGlobal 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 ;Open the SDL2 DLL Global $SDL = ("SDL2.dll") Func SDL_Init($flags) Local $xSDL_Init = DllCall($SDL,"int:cdecl","SDL_Init","uint", $flags) Return $xSDL_Init[0] EndFunc Func SDL_Quit() $xSDL_Quit = DllCall($SDL,"none:cdecl","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:cdecl","SDL_DestroyWindow","ptr",$win) Return $xSDL_DestroyWindow[0] EndFunc Func SDL_Delay($ms) Local $xSDL_Delay = DllCall($SDL,"none:cdecl","SDL_Delay","uint",$ms) Return $xSDL_Delay[0] EndFunc DllClose($SDL) Your sample 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() Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
LeftyGuitar Posted May 1, 2018 Author Share Posted May 1, 2018 Global $SDL = ("SDL2.dll") ;Check to make sure SDL2 DLL is there if $SDL = -1 Then MsgBox($MB_SYSTEMMODAL,"Error","Could not load SDL2.dll!\n") EndIf Func SDL_Init($flags) Local $xSDL_Init = DllCall($SDL,"int:cdecl","SDL_Init","uint", $flags) If @error Then Return SetError(1, @error, -1) Return $xSDL_Init[0] EndFunc Func SDL_Quit() $xSDL_Quit = DllCall($SDL,"none:cdecl","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) If @error Then Return SetError(1, @error, -1) Return $xSDL_CreateWindow[0] EndFunc Func SDL_DestroyWindow($win) $xSDL_DestroyWindow = DllCall($SDL,"none:cdecl","SDL_DestroyWindow","ptr",$win) Return $xSDL_DestroyWindow[0] EndFunc Func SDL_Delay($ms) Local $xSDL_Delay = DllCall($SDL,"none:cdecl","SDL_Delay","uint",$ms) Return $xSDL_Delay[0] EndFunc #include <SDL2.au3> Local $w = 640, $h = 480 Local $x = SDL_Init($SDL_INIT_VIDEO) If $x = -1 Then MsgBox(1,"Error","Could not init SDL!") EndIf Local $win = SDL_CreateWindow("MyWin",$SDL_WINDOWPOS_CENTERED,$SDL_WINDOWPOS_CENTERED,$w,$h,$SDL_WINDOW_SHOWN) if $win = -1 Then MsgBox(1,"Error","Could not make window") EndIf SDL_Delay(3000) SDL_DestroyWindow($win) SDL_Quit() Thanks, I added those into my wrapper code, but when I test the sample program, it still comes up with the this program has stop responding message. I ran a check on the DLL and the functions are in the DLL. I'm not sure if it might be conflicting with something else or I'm missing something that could be really simple. Link to comment Share on other sites More sharing options...
Danyfirex Posted May 1, 2018 Share Posted May 1, 2018 Strange Its working great for me. I'm using lib Version FileVersion 2, 0, 8, 0 MD5: BB59DA9C8E2BC1AA686B3111629D2312 Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
LeftyGuitar Posted May 1, 2018 Author Share Posted May 1, 2018 (edited) I'm also using SDL 2.0.8.0, the x86 version of the SDL2 for compatibility reasons. What I posted of the wrapper code was a just small sample, I'm trying to wrap most of the functions from the DLL. I have the whole wrapper here: https://github.com/gAndy50/AuotIt_Wrappers/blob/master/SDL2.au3 I'm not sure if there could be something conflicting with something else, but when I compile the wrapper code it comes up with no errors, same as when I hit Go(F5) and still no errors. There's also no errors when I compile the sample program, it just crashes after the three seconds are up. It does come up with Exit code: 3221225477, when I try to run the sample program. Edited May 1, 2018 by LeftyGuitar Link to comment Share on other sites More sharing options...
Danyfirex Posted May 1, 2018 Share Posted May 1, 2018 try this version: expandcollapse popupGlobal 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 Global $g_hSDL = 0 Func SDL_Init($flags) $g_hSDL = DllOpen("SDL2.dll") If @error Then Return SetError(1, @error, -1) Local $xSDL_Init = DllCall($g_hSDL, "int:cdecl", "SDL_Init", "uint", $flags) If @error Then Return SetError(1, @error, -1) Return $xSDL_Init[0] EndFunc ;==>SDL_Init Func SDL_Quit() $xSDL_Quit = DllCall($g_hSDL, "none:cdecl", "SDL_Quit") Return $xSDL_Quit[0] EndFunc ;==>SDL_Quit Func SDL_CreateWindow($title, $x, $y, $w, $h, $flags) Local $xSDL_CreateWindow = DllCall($g_hSDL, "ptr:cdecl", "SDL_CreateWindow", "str", $title, "int", $x, "int", $y, "int", $w, "int", $h, "uint", $flags) If @error Then Return SetError(1, @error, -1) Return $xSDL_CreateWindow[0] EndFunc ;==>SDL_CreateWindow Func SDL_DestroyWindow($win) $xSDL_DestroyWindow = DllCall($g_hSDL, "none:cdecl", "SDL_DestroyWindow", "ptr", $win) Return $xSDL_DestroyWindow[0] EndFunc ;==>SDL_DestroyWindow Func SDL_Delay($ms) Local $xSDL_Delay = DllCall($g_hSDL, "none:cdecl", "SDL_Delay", "uint", $ms) Return $xSDL_Delay[0] EndFunc ;==>SDL_Delay Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
LeftyGuitar Posted May 1, 2018 Author Share Posted May 1, 2018 Hello, thanks, it is working now. I did this: ;Open the SDL2 DLL Global $SDL = 0 ;("SDL2.dll") ;Check to make sure SDL2 DLL is there if $SDL = -1 Then MsgBox($MB_SYSTEMMODAL,"Error","Could not load SDL2.dll!\n") EndIf ;SDL Init Functions Func SDL_Init($flags) $SDL = DllOpen("SDL2.dll") If @error Then Return SetError(1, @error, -1) Local $xSDL_Init = DllCall($SDL,"int:cdecl","SDL_Init","uint", $flags) If @error Then Return SetError(1, @error, -1) Return $xSDL_Init[0] EndFunc Func SDL_Quit() $xSDL_Quit = DllCall($SDL,"none:cdecl","SDL_Quit") If @error Then Return SetError(1, @error, -1) Return $xSDL_Quit[0] EndFunc Link to comment Share on other sites More sharing options...
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