raylib-wasm 0.0.18

raylib native/wasm bindings
Documentation
#[cfg(not(feature = "web"))]
use crate::native_fns::*;
use crate::small_c_string::run_with_cstr;
use crate::structs::*;
#[cfg(feature = "web")]
use crate::web_fns::*;

#[inline]
pub fn init_window(w: i32, h: i32, title: &str) {
    run_with_cstr(title.as_bytes(), |ctitle| unsafe {
        InitWindow(w, h, ctitle.as_ptr());
    })
}

#[inline]
pub fn measure_text(text: &str, font_size: usize) -> i32 {
    let mut m: i32 = 0;
    run_with_cstr(text.as_bytes(), |text| unsafe {
        m = MeasureText(text.as_ptr(), font_size as i32);
    });
    return m;
}

#[inline]
pub fn draw_text(text: &str, x: i32, y: i32, font_size: usize, color: Color) {
    run_with_cstr(text.as_bytes(), |text| unsafe {
        DrawText(text.as_ptr(), x, y, font_size as i32, color);
    })
}

#[inline]
pub fn load_texture(filename: &str) -> Texture {
    let mut t: Texture = Texture {
        id: 0,
        width: 0,
        height: 0,
        mipmaps: 0,
        format: 0,
    };
    run_with_cstr(filename.as_bytes(), |filename| unsafe {
        t = LoadTexture(filename.as_ptr());
    });
    return t;
}