Skip to content

Instantly share code, notes, and snippets.

@newvertex
Last active August 3, 2021 15:00
Show Gist options
  • Save newvertex/41fdc3b9435005925d4c36e753217185 to your computer and use it in GitHub Desktop.
Save newvertex/41fdc3b9435005925d4c36e753217185 to your computer and use it in GitHub Desktop.
Simple Helper function to get string (&str) from *const u8 for using with gl in Rust Lang
// get OpenGL version in rust
fn gl_get_string<'a>(name: gl::types::GLenum) -> &'a str {
let v: *const u8 = unsafe { gl::GetString(name) };
let v: &std::ffi::CStr = unsafe { std::ffi::CStr::from_ptr(v as *const i8) };
v.to_str().unwrap()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment