#pragma once

#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
#include <memory>
#include <string>

namespace quokka_gfx
{
//------------------------------------------------------------
using HashID  = uint32_t;
using Texture = std::unique_ptr<SDL_Texture, void (*)(SDL_Texture *)>;
using Font    = std::unique_ptr<TTF_Font, void (*)(TTF_Font *)>;
//------------------------------------------------------------
// Hash function for IDs using FNV-1a algorithm
inline constexpr HashID toID(const std::string &id)
{
  constexpr uint32_t FNV_offset_basis = 2166136261u;
  constexpr uint32_t FNV_prime        = 16777619u;

  uint32_t hash_value = FNV_offset_basis;
  for (const char c : id)
  {
    hash_value ^= static_cast<uint32_t>(static_cast<uint8_t>(c));
    hash_value *= FNV_prime;
  }
  return hash_value;
}
//------------------------------------------------------------
}     // namespace quokka_gfx
