extern crate serde_json;

use vulkan::gameobject::GameObject;

use crate::config::{LogConfig, RenderConfig};
use crate::game::TestGame;
use crate::vulkan::{LinePoint, VulkanRenderer};

mod vulkan;
mod input;
mod config;
mod game;
mod tests;

fn main() {
    let log_config = LogConfig::from_file("config/log.toml");

    let mut game = TestGame::new("config/input.toml", log_config);

    let line_count = 30;
    let line_vertices = (-line_count..=line_count)
        .flat_map(|it| vec![
            LinePoint { position: [it as f32, 0., -line_count as f32] },
            LinePoint { position: [it as f32, 0., line_count as f32] },
            LinePoint { position: [-line_count as f32, 0., it as f32] },
            LinePoint { position: [line_count as f32, 0., it as f32] },
        ]).collect();

    let (mut renderer, event_loop) = VulkanRenderer::init(
        line_vertices,
        log_config.vulkan_validation_layers,
        RenderConfig::from_file("config/graphics.toml")
    );

    game.game_start(&mut renderer);
    vulkan::start_event_loop(renderer, Box::new(game), event_loop);
}
