Hello! I've been trying out a bunch of wrappers for raylib in different languages, so I've been playing around with some simple font rendering code that i've been porting around. So far, I think I like raylib-rs the best of everything i've tried, but I did notice a problem with how types are being wrapped in the library.
For example, let's say you create a Font like this, and try to change the texture filter:
let mut font = rl.load_font("res/MyFont.ttf");
rl.set_texture_filter(&font.texture, TextureFilter::Point);
Doing this will give you a compilation error, because font.texture is a ffi:Texture2D, not one of the "safe" Texture2Ds.
I believe the problem is that the make_thin_wrapper! macro isn't smart enough to understand that the members have to be wrapped. Probably any FFI types that have non-primitive fields (Font, Material, Shader, etc) need to be implemented manually instead of using a macro, so it's not just a problem with Font and Texture2D.
I would try to make a patch, but I'm fairly new to rust and not sure exactly how to best expose a "safe" Texture2D but that doesn't hold ownership (a Font already maintains its Texture2D, so the exposed font.texture should only have a reference). Maybe you have some ideas?
Hello! I've been trying out a bunch of wrappers for raylib in different languages, so I've been playing around with some simple font rendering code that i've been porting around. So far, I think I like raylib-rs the best of everything i've tried, but I did notice a problem with how types are being wrapped in the library.
For example, let's say you create a
Font
like this, and try to change the texture filter:Doing this will give you a compilation error, because
font.texture
is affi:Texture2D
, not one of the "safe"Texture2D
s.I believe the problem is that the
make_thin_wrapper!
macro isn't smart enough to understand that the members have to be wrapped. Probably any FFI types that have non-primitive fields (Font, Material, Shader, etc) need to be implemented manually instead of using a macro, so it's not just a problem with Font and Texture2D.I would try to make a patch, but I'm fairly new to rust and not sure exactly how to best expose a "safe" Texture2D but that doesn't hold ownership (a Font already maintains its Texture2D, so the exposed
font.texture
should only have a reference). Maybe you have some ideas?