SDL2 Init Problem
- Posted by Lone_EverGreen_Ranger Jun 26, 2013
- 3715 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?