1. SDL 2 Wrapper using FFI


I have recently re-wrote(well some copy and paste and modifications here and there) to adapt with the new FFI library that was recently made by Greg. Its pretty much done except for the hints functions. I have a couple demo programs. I haven't uploaded the library yet as I'm still working on the finishing touches. Just wondering if you guys are interested or have any feedback?

Oh I have written the library to more closely match SDL in terms of C source. For example SDL.h becmes SDL.e and so forth.

--EuSDL2						   -- 
--Written by Andy P. (Icy_Viking)  -- 
--SDL Ver: 2.24.1				   -- 
--Euphoria Ver: 4.1.0 Beta 2	   -- 
--Using FFI for Euphoria		   -- 
--Icy Viking Games				   -- 
without warning 
include std/machine.e 
include std/ffi.e --replaces std/dll.e 
include std/os.e  
include std/math.e --for or_all({}) function 
public atom sdl = 0 
--Load shared library for OS 
ifdef WINDOWS then 
	sdl = open_dll("SDL2.dll") 
	elsifdef LINUX or FREEBSD then 
	sdl = open_dll("SDL2.so") 
end ifdef 
--SDL include files 
public include SDL_assert.e 
public include SDL_atomic.e 
public include SDL_audio.e 
public include SDL_clipboard.e 
public include SDL_cpuinfo.e 
public include SDL_endian.e 
public include SDL_error.e 
public include SDL_events.e 
public include SDL_filesystem.e 
public include SDL_gamecontroller.e 
public include SDL_guid.e 
public include SDL_haptic.e 
public include SDL_hidapi.e 
--public include SDL_hints.e 
public include SDL_joystick.e 
public include SDL_loadso.e 
public include SDL_log.e 
public include SDL_messagebox.e 
public include SDL_metal.e 
public include SDL_mutex.e 
public include SDL_power.e 
public include SDL_pixels.e 
public include SDL_surface.e 
public include SDL_render.e 
public include SDL_rwops.e 
public include SDL_shape.e 
--public include SDL_system.e 
public include SDL_thread.e 
public include SDL_timer.e 
public include SDL_version.e 
public include SDL_video.e 
public include SDL_locale.e 
public include SDL_misc.e 
--SDL Init Flags 
public constant SDL_INIT_TIMER = 0x00000001, 
				SDL_INIT_AUDIO = 0x00000010, 
				SDL_INIT_VIDEO = 0x00000020, 
				SDL_INIT_JOYSTICK = 0x00000200, 
				SDL_INIT_HAPTIC = 0x00001000, 
				SDL_INIT_GAMECONTROLLER = 0x00002000, 
				SDL_INIT_EVENTS = 0x00004000, 
				SDL_INIT_SENSOR = 0x00008000, 
				SDL_INIT_NOPARACHUTE = 0x00100000 
export 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 
export constant xSDL_InitSubSystem = define_c_func(sdl,"+SDL_InitSubSystem",{C_UINT},C_INT) 
public function SDL_InitSubSystem(atom flags) 
	return c_func(xSDL_InitSubSystem,{flags}) 
end function 
export constant xSDL_QuitSubSystem = define_c_proc(sdl,"+SDL_QuitSubSystm",{C_UINT}) 
public procedure SDL_QuitSubSystem(atom flags) 
end procedure 
export constant xSDL_WasInit = define_c_func(sdl,"+SDL_WasInit",{C_UINT},C_UINT) 
public function SDL_WasInit(atom flags) 
	return c_func(xSDL_WasInit,{flags}) 
end function 
export constant xSDL_Quit = define_c_proc(sdl,"+SDL_Quit",{}) 
public procedure SDL_Quit() 
end procedure 
--Show CPU Info Demo 
include sdl.e 
puts(1,"1 Means True, 0 Means False\n") 
printf(1,"CPU Count: %d\n",{SDL_GetCPUCount() }) 
printf(1,"Cache Line Size: %d\n",{SDL_GetCPUCacheLineSize() }) 
printf(1,"Has RDTSC: %d\n",{SDL_HasRDTSC() }) 
printf(1,"Has AtltiVec: %d\n",{SDL_HasAltiVec() }) 
printf(1,"Has MMX:%d\n",{SDL_HasMMX() }) 
printf(1,"Has 3D Now:%d\n",{SDL_Has3DNow() }) 
printf(1,"Has SSE:%d\n",{SDL_HasSSE() }) 
printf(1,"Has SSE2:%d\n",{SDL_HasSSE2() }) 
printf(1,"Has SSE3:%d\n",{SDL_HasSSE3() }) 
printf(1,"Has SSE41:%d\n",{SDL_HasSSE41() }) 
printf(1,"Has SSE42:%d\n",{SDL_HasSSE42() }) 
printf(1,"Has AVX:%d\n",{SDL_HasAVX() }) 
printf(1,"Has AVX2:%d\n",{SDL_HasAVX2() }) 
printf(1,"Has AVX512F:%d\n",{SDL_HasAVX512F() }) 
printf(1,"Has ARMSIMD:%d\n",{SDL_HasARMSIMD() }) 
printf(1,"Has NEON:%d\n",{SDL_HasNEON() }) 
printf(1,"Has LSX:%d\n",{SDL_HasLSX() }) 
printf(1,"Has LASX:%d\n",{SDL_HasLASX() }) 
printf(1,"RAM: %d",{SDL_GetSystemRAM() }) 
--Simple Window 
--SDL2 Wrapper for Euphoria 
include std/ffi.e 
include sdl.e 
--include SDL_pixels.e 
constant MAX_WIDTH = 640, 
		 MAX_HEIGHT = 480 
procedure main() 
 atom win = 0 
 object surf = {} 
 sequence rect = {} 
 if SDL_Init(SDL_INIT_VIDEO) = -1 then 
 	puts(1,"Failed to init SDL!\n") 
 end if 
 if win = -1 then 
 	puts(1,"Failed to create window!\n") 
 end if 
 surf = SDL_GetWindowSurface(win) 
 SDL_Delay(3000) --3 seconds 
end procedure 
new topic     » topic index » view message » categorize

2. Re: SDL 2 Wrapper using FFI

Hello Hot viking,
You don't have to call yourself "Icy viking". Everybody knows you are "hot" as far low level programming goes. Will certainly wait for your new version of SDL2 wrapper.

new topic     » goto parent     » topic index » view message » categorize


Quick Links

User menu

Not signed in.

Misc Menu