nightshade 0.13.3

A cross-platform data-oriented game engine.
Documentation
//! Renderer creation and backend selection.
//!
//! Provides [`create_renderer`] which constructs the appropriate rendering backend
//! based on enabled features. Currently supports wgpu (the default and only backend).

pub use crate::ecs::world::Render;

pub async fn create_renderer<W>(
    window_handle: W,
    initial_width: u32,
    initial_height: u32,
) -> std::result::Result<Box<dyn Render>, Box<dyn std::error::Error>>
where
    W: raw_window_handle::HasDisplayHandle
        + raw_window_handle::HasWindowHandle
        + Send
        + Sync
        + 'static,
{
    #[cfg(feature = "wgpu")]
    {
        let wgpu_renderer =
            crate::render::wgpu::create_wgpu_renderer(window_handle, initial_width, initial_height)
                .await?;
        Ok(Box::new(wgpu_renderer))
    }

    #[cfg(not(feature = "wgpu"))]
    {
        Err("No renderer backend enabled".into())
    }
}