use serde::{Deserialize, Serialize};

#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum DisplayMode {
    Wireframe,
    HiddenLineRemoved,
    HiddenLineGray,
    ShadedWithEdges,
    ShadedNoEdges,
}

impl DisplayMode {
    pub const DEFAULT: Self = Self::ShadedWithEdges;

    #[must_use]
    pub const fn label(self) -> &'static str {
        match self {
            Self::Wireframe => "wireframe",
            Self::HiddenLineRemoved => "hidden_line_removed",
            Self::HiddenLineGray => "hidden_line_gray",
            Self::ShadedWithEdges => "shaded_with_edges",
            Self::ShadedNoEdges => "shaded_no_edges",
        }
    }
}

impl core::fmt::Display for DisplayMode {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        f.write_str(self.label())
    }
}

#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ShadingModel {
    Flat,
    Gouraud,
    Phong,
}

impl ShadingModel {
    #[must_use]
    pub const fn label(self) -> &'static str {
        match self {
            Self::Flat => "flat",
            Self::Gouraud => "gouraud",
            Self::Phong => "phong",
        }
    }
}

impl core::fmt::Display for ShadingModel {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        f.write_str(self.label())
    }
}
