Re: Irony of this SFML C Port

new topic     » goto parent     » topic index » view thread      » older message » newer message
ChrisB said...
Icy_Viking said...

Hi all,

I was recently going to see if CSFML had updated for 3.1.0 as the normal C+ library is at 3.1.0. However I came across this [https://github.com/unwanted666dkjf/SSW_SFML3/blob/main/headers/system/sf_vector2f.h]

As you can see this would have been good for Euphoria prior to Greg having made his FFI library. Regardless Greg's FFI library has been a great help in wrapping libraries. I am thinking about wrapping this for fun. Just thought it was a fun nod.

Hi Andy - explain as if I am Trump please.

Cheers Chris

Hi Chris, if you take a look at the source file I linked, it has a function called sf_Vector2f_init(float x,float y), this would be straight forward to wrap in Euphoria without having struct support that the FFI library provides. Wrapping this port would not require to have any struct support is the most basic thing about it. Everything is wrapped in this C Port without needing to have structs.

constant xsf_Vector2f_init = define_c_func(C_FLOAT,C_FLOAT},C_POINTER) 
 
public function sf_Vector2f_init(atom x,atom y) 
 return c_func(xsf_Vector2f_Init,{x,y}) 
end function 
--With FFI 
 
public constant sfVector2 = define_c_struct({ 
  C_FLOAT, --x 
  C_FLOAT  --y 
}) 
 
public constant xsfFloatRect_contains = define_c_func(gfx,"+sfFloatRect_contains",{C_POINTER,sfVector2f},C_BOOL) 
 
public function sfFloatRect_contains(atom rect,sequence point) 
	return c_func(xsfFloatRect_contains,{rect,point}) 
end function 
 
--With FFI struct support you can use sequences to call structs where point[1] would be x and point[2] would be y 
--You could also use enums to make the code more readable 
 
enum x,y 
point[x],point[y] 

However I prefer having struct support and using the FFI library, I find its better to keep the euphoria wrapper as close to C version as possible. Regardless I may or may not wrap this out of fun or boredom. We'll see.

Also, I agree Make Euphoria Great Again!

Haha

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu