1. SDL2 Init Problem
- Posted by Lone_EverGreen_Ranger Jun 26, 2013
- 3716 views
Hello,
After having got my wrapper to open the DLL correctly, I am now having another issue. It appears SDL is not being initialized for whatever reason. However when I tried another function from the wrapper, it worked correctly. I'll post my code below.
Test Program: It is saying SDL is not being initailized, but it shows the correct number of CPUs.
with trace include EuSDL2.ew trace(2) atom dummy = SDL_Init(SDL_INIT_VIDEO) atom x x = SDL_GetCPUCount() if dummy = -1 then puts(1,"Could not init SDL") end if printf(1,"CPUs: %d",{x})
Wrapper code:
public constant SDL_INIT_TIMER = 000000001 public constant SDL_INIT_AUDIO = 000000010 public constant SDL_INIT_VIDEO = 000000020 public constant SDL_INIT_JOYSTICK = 000000200 public constant SDL_INIT_HAPTIC = 000001000 public constant SDL_INIT_GAMECONTROLLER = 000002000 public constant SDL_INIT_NOPARACHUTE = 000100000 public constant SDL_INIT_EVERYTHING = #0000FFFF public constant xSDL_Init = define_c_func(sdl,"SDL_Init",{C_UINT},C_INT), xSDL_InitSubSystem = define_c_func(sdl,"SDL_InitSubSystem",{C_UINT},C_INT), xSDL_Quit = define_c_proc(sdl,"SDL_Quit",{}), xSDL_QuitSubSystem = define_c_proc(sdl,"SDL_QuitSubSystem",{C_UINT}), xSDL_WasInit = define_c_func(sdl,"SDL_WasInit",{C_UINT},C_UINT) public function SDL_Init(atom flags) return c_func(xSDL_Init,{flags}) end function if xSDL_Init = -1 then puts(1,"Could not load SDL_Init") end if public function SDL_InitSubSystem(atom flags) return c_func(xSDL_InitSubSystem,{flags}) end function if xSDL_InitSubSystem = -1 then puts(1,"Could not load SDL_InitSubsystem!") end if public procedure SDL_QuitSubSystem(atom flags) c_proc(xSDL_QuitSubSystem,{flags}) end procedure if xSDL_QuitSubSystem = -1 then puts(1,"Could not load SDL_QuitSubSystem") end if public procedure SDL_Quit() c_proc(xSDL_Quit,{}) end procedure if xSDL_Quit = -1 then puts(1,"Could not load SDL_Quit") end if public function SDL_WasInit(atom flags) return c_func(xSDL_WasInit,{flags}) end function if xSDL_WasInit = -1 then puts(1,"Could not load SDL_WasInit") end if
Sorry if its a little too much code, but I am not sure why SDL is not being initialized. When I ran it with tracer on, it pointed to the SDL_Init function, but I'm not sure what I'm doing wrong there. It says flags = 20 for SDL_Init, Any help?
2. Re: SDL2 Init Problem
- Posted by jimcbrown (admin) Jun 27, 2013
- 3576 views
Hello,
After having got my wrapper to open the DLL correctly, I am now having another issue. It appears SDL is not being initialized for whatever reason. However when I tried another function from the wrapper, it worked correctly. I'll post my code below.
Wrapper code:
public constant SDL_INIT_TIMER = 000000001 public constant SDL_INIT_AUDIO = 000000010 public constant SDL_INIT_VIDEO = 000000020 public constant SDL_INIT_JOYSTICK = 000000200 public constant SDL_INIT_HAPTIC = 000001000 public constant SDL_INIT_GAMECONTROLLER = 000002000 public constant SDL_INIT_NOPARACHUTE = 000100000 public constant SDL_INIT_EVERYTHING = #0000FFFF
Most of your flags are wrong. E.g., SDL_INIT_VIDEO isn't 20 but #000000020 or 32 in decimal.
Only SDL_INIT_TIMER (because 1 is the same in decimal or hexadecimal) and SDL_INIT_EVERYTHING (which is specified in hexadecimal format) are correct.
Test Program: It is saying SDL is not being initailized, but it shows the correct number of CPUs.
Probably, SDL_GetCpuCount() can be called before SDL's initialization. This function doesn't look like it fits into the categories of VIDEO, AUDIO, JOYSTICK, HAPTIC, TIMER, etc.
3. Re: SDL2 Init Problem
- Posted by Lone_EverGreen_Ranger Jun 27, 2013
- 3568 views
Thanks for the help, I'll have to look more the hex and decimal values.
4. Re: SDL2 Init Problem
- Posted by ghaberek (admin) Jun 27, 2013
- 3541 views
public constant xSDL_Init = define_c_func(sdl,"SDL_Init",{C_UINT},C_INT) public function SDL_Init(atom flags) return c_func(xSDL_Init,{flags}) end function if xSDL_Init = -1 then puts(1,"Could not load SDL_Init") end if
Please have a look at my extended dynamic linking routines. I really think it will help your efforts here. Especially all those "if xFunction = -1" lines.
-Greg
5. Re: SDL2 Init Problem
- Posted by Lone_EverGreen_Ranger Jun 27, 2013
- 3508 views
Yes I have tried using the advDLL, but still not getting errors. I have changed the flags to decimal values, and I am still getting the SDL could not be initalized error.
EDIT: It appears that wrapper works, as when I made a simple test to show a window, it came up.
6. Re: SDL2 Init Problem
- Posted by ChrisB (moderator) Mar 27, 2014
- 3168 views
Hi
Have you solved the could not init SDL problem yet? I just tried the examples, and am getting the same error.
Chris
7. Re: SDL2 Init Problem
- Posted by Lone_EverGreen_Ranger Mar 27, 2014
- 3179 views
Hi
Have you solved the could not init SDL problem yet? I just tried the examples, and am getting the same error.
Chris
I have not been able to solve the problem completley as of yet. However the wrapper works. I suspect it is some odd bug.
8. Re: SDL2 Init Problem
- Posted by ChrisB (moderator) Mar 28, 2014
- 3330 views
I have not been able to solve the problem completley as of yet. However the wrapper works. I suspect it is some odd bug.
Ah, the best sort!
Chris
9. Re: SDL2 Init Problem
- Posted by ChrisB (moderator) Apr 08, 2014
- 2690 views
Hi
Found 3 dependencies that sdl2 was missing.
gdiplus.dll
msjava.dll
invalid
These were found by dependency walker.
Invalid seems to be within ntdll.dll (and not 100% sure what this means)
Installed gdiplus and msjava.dll, these dependencies went away, but there seems to be problem with ntdll.dll - tried updating this#, and again made no difference. Incidentally, deleting ntdll.dll from /system32 had no effect, as it was re installed from /system32/dllcache - so I replaced this one, after backing it up, then deleted the /system32 copy - windows replaced it, then complained, whiuch I told it to ignore, but still sdl2 could not init.
Is sdl2 working on other platforms (i was using 32 bit xp)
Chris
10. Re: SDL2 Init Problem
- Posted by Lone_EverGreen_Ranger Apr 08, 2014
- 2664 views
I've only tested it under Windows 7 Ultimate 64-bit. The wrapper appears to work fine except for that odd bug. I haven't tested it on other platforms.