use wgpu::CommandEncoder;
use bytemuck::{Pod, Zeroable};

pub mod state;
pub mod system;


#[cfg_attr(rustfmt, rustfmt_skip)]
#[allow(unused)]
pub const OPENGL_TO_WGPU_MATRIX: cgmath::Matrix4<f32> = cgmath::Matrix4::new(
    1.0, 0.0, 0.0, 0.0,
    0.0, 1.0, 0.0, 0.0,
    0.0, 0.0, 0.5, 0.0,
    0.0, 0.0, 0.5, 1.0,
);


// I dont even wanna talk about this
lazy_static! {
    static ref INTEL_DEBUG_SHINANIGANS : bool = std::env::var("INTEL_FIX").map_or(false, |a| true);
}

fn insert_debug_marker_checked(name: &str, command_encoder: &mut CommandEncoder) {
    if !*INTEL_DEBUG_SHINANIGANS {
        command_encoder.insert_debug_marker(name);
    }
}

fn push_debug_group_checked(name: &str, command_encoder: &mut CommandEncoder) {
    if !*INTEL_DEBUG_SHINANIGANS {
        command_encoder.push_debug_group(name);
    }
}

fn pop_debug_group_checked(command_encoder: &mut CommandEncoder) {
    if !*INTEL_DEBUG_SHINANIGANS {
        command_encoder.pop_debug_group();
    }
}

#[repr(C)]
#[derive(Clone, Copy)]
pub struct ForwardUniforms {
    proj: [[f32; 4]; 4],
    num_lights: [u32; 4],
}

unsafe impl Pod for ForwardUniforms {}
unsafe impl Zeroable for ForwardUniforms {}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct EntityUniforms {
    model: [[f32; 4]; 4],
    color: [f32; 4],
}

unsafe impl Pod for EntityUniforms {}
unsafe impl Zeroable for EntityUniforms {}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct ShadowUniforms {
    proj: [[f32; 4]; 4],
}

unsafe impl Pod for ShadowUniforms {}
unsafe impl Zeroable for ShadowUniforms {}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct CameraProjectionView {
    proj: [[f32; 4]; 4],
}

unsafe impl Pod for CameraProjectionView {}
unsafe impl Zeroable for CameraProjectionView {}