#pragma once

#include <array>

#define VULKAN_HPP_NO_CONSTRUCTORS
#include <vulkan/vulkan.hpp>

#include "types.hpp"

struct CrosshairVertex {
  vec2 pos;
  vec3 color;

  static fn getBindingDescription() -> vk::VertexInputBindingDescription {
    return { .binding = 0, .stride = sizeof(CrosshairVertex), .inputRate = vk::VertexInputRate::eVertex };
  }

  static fn getAttributeDescriptions() -> std::array<vk::VertexInputAttributeDescription, 2> {
    return {
      vk::VertexInputAttributeDescription { .location = 0,
                                           .binding  = 0,
                                           .format   = vk::Format::eR32G32Sfloat,
                                           .offset   = offsetof(CrosshairVertex,   pos) },
      vk::VertexInputAttributeDescription { .location = 1,
                                           .binding  = 0,
                                           .format   = vk::Format::eR32G32B32Sfloat,
                                           .offset   = offsetof(CrosshairVertex, color) }
    };
  }
};

// Crosshair vertices (in normalized device coordinates)
constexpr f32                            CROSSHAIR_SIZE    = 0.02F;
constexpr std::array<CrosshairVertex, 4> crosshairVertices = {
  // Horizontal line
  CrosshairVertex { { -CROSSHAIR_SIZE * (9.0F / 16.0F), 0.0F }, { 1.0F, 1.0F, 1.0F } }, // Left
  CrosshairVertex {  { CROSSHAIR_SIZE * (9.0F / 16.0F), 0.0F }, { 1.0F, 1.0F, 1.0F } }, // Right
  // Vertical line
  CrosshairVertex {                  { 0.0F, -CROSSHAIR_SIZE }, { 1.0F, 1.0F, 1.0F } }, // Bottom
  CrosshairVertex {                   { 0.0F, CROSSHAIR_SIZE }, { 1.0F, 1.0F, 1.0F } }  // Top
};

// Indices for drawing the crosshair lines
constexpr std::array<u16, 4> crosshairIndices = {
  0,
  1, // Horizontal line
  2,
  3 // Vertical line
};
