xplane11-sys

git clone git://archive.git.mtrnord.blog/MTRNord/xplane11-sys.git
Log | Files | Refs | README | LICENSE

graphics.rs (776B)


      1 use crate::bindings;
      2 
      3 pub fn XPLMDrawString(
      4     mut color: [f32; 3],
      5     xOffset: i32,
      6     yOffset: i32,
      7     string: &str,
      8     wordWrapWidth: Option<i32>,
      9     fontID: bindings::XPLMFontID,
     10 ) {
     11     let bytes = String::from(format!("{}\0", string)).into_bytes();
     12     let mut cchars: Vec<::std::os::raw::c_char> =
     13         bytes.iter().map(|&b| b as ::std::os::raw::c_char).collect();
     14     let text: *mut ::std::os::raw::c_char = cchars.as_mut_ptr();
     15     let wordWrapWidthl = match wordWrapWidth {
     16         Some(mut v) => &mut v,
     17         None => std::ptr::null_mut(),
     18     };
     19     unsafe {
     20         bindings::XPLMDrawString(
     21             color.as_mut_ptr(),
     22             xOffset,
     23             yOffset,
     24             text,
     25             wordWrapWidthl,
     26             fontID,
     27         )
     28     };
     29 }