1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use std::ffi::CStr;
use std::fmt;
use crate::sys;
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct Version {
pub major: u8,
pub minor: u8,
pub patch: u8,
}
impl Version {
pub fn from_ll(v: sys::SDL_version) -> Version {
Version { major: v.major, minor: v.minor, patch: v.patch }
}
}
impl fmt::Display for Version {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}.{}.{}", self.major, self.minor, self.patch)
}
}
pub fn version() -> Version {
unsafe {
let mut cver = sys::SDL_version { major: 0, minor: 0, patch: 0};
sys::SDL_GetVersion(&mut cver);
Version::from_ll(cver)
}
}
pub fn revision() -> String {
unsafe {
let rev = sys::SDL_GetRevision();
CStr::from_ptr(rev as *const _).to_str().unwrap().to_owned()
}
}
pub fn revision_number() -> i32 {
unsafe {
sys::SDL_GetRevisionNumber()
}
}