1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//! Drivers of renderers.

use std::mem::MaybeUninit;

use super::info::RendererInfo;
use crate::bind;

/// Returns the list of render driver information.
#[must_use]
pub fn drivers() -> Vec<RendererInfo> {
    let num = unsafe {
        bind::SDL_InitSubSystem(bind::SDL_INIT_VIDEO);
        bind::SDL_GetNumRenderDrivers()
    };
    (0..num)
        .map(|index| {
            let mut info = MaybeUninit::<bind::SDL_RendererInfo>::uninit();
            let ret = unsafe { bind::SDL_GetRenderDriverInfo(index, info.as_mut_ptr()) };
            unsafe { info.assume_init() }.into()
        })
        .collect()
}