Last active
August 3, 2021 15:00
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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