1. FFI Library is Gold!

Hey all,

So I wanted to see how much Greg's FFI Euphoria library would help with wrapping SFML. To my surprise it has helped a lot. For example

--Wrapper Code 
include std/ffi.e 
include Window.e 
 
public constant sfVideoMode = define_c_struct({ 
	C_UINT, --width 
	C_UINT, --height 
	C_UINT --bitsPerPixel 
}) 
export constant xsfRenderWindow_create = define_c_func(gfx,"+sfRenderWindow_create",{sfVideoMode,C_STRING,C_UINT32,C_POINTER},C_POINTER) 
 
public function sfRenderWindow_create(sequence mode,sequence title,atom style,atom set) 
	return c_func(xsfRenderWindow_create,{mode,title,style,set}) 
end function 
--Simple Example 
include std/ffi.e 
 
include System.e 
include Window.e 
include Event.e 
include Graphics.e 
 
sequence mode = {1024,720,32} --width,height,-bitsPerPixel 
 
atom win = sfRenderWindow_create(mode,"Simple Example",sfClose,0) 
 
atom evt = allocate_struct(sfEvent) 
atom evt_type = 0 
 
sfRenderWindow_setFramerateLimit(win,60) 
 
while sfRenderWindow_isOpen(win) do 
	while sfRenderWindow_pollEvent(win,evt) do 
		evt_type = peek_type(evt,C_INT) 
		if evt_type = sfEvtClosed then 
			sfRenderWindow_close(win) 
		end if 
	end while 
	sfRenderWindow_clear(win,sfBlack) 
	sfRenderWindow_display(win) 
end while 
 
sfRenderWindow_destroy(win) 

Not all of my code is shown, but I'm sure from what I've posted, you can notice the changes compared to how my old wrapper was written. I mostly did this as a test and out of boredom. I'm not sure how much I'll continue it, but I may. Also, the FFI library has proven to be coding gold, special thanks to Greg for making it.

new topic     » topic index » view message » categorize

2. Re: FFI Library is Gold!

Icy_Viking said...

the FFI library has proven to be coding gold, special thanks to Greg for making it.

You're welcome! The biggest thanks go to Anthony Green and the contributors of libffi for making it possible.

I'm still working on the backend and standard library integration but that should be ready soon enough. I've had to rework a few bits I'm doing some things in C now.

-Greg

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

3. Re: FFI Library is Gold!

ghaberek said...
Icy_Viking said...

the FFI library has proven to be coding gold, special thanks to Greg for making it.

You're welcome! The biggest thanks go to Anthony Green and the contributors of libffi for making it possible.

I'm still working on the backend and standard library integration but that should be ready soon enough. I've had to rework a few bits I'm doing some things in C now.

-Greg

Indeed. Keep doing what you're doing. I'm hoping Eu 4.2.0 will get released this year!

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

Search



Quick Links

User menu

Not signed in.

Misc Menu