#ifndef mosaic_bkgr_hh
#define mosaic_bkgr_hh

#include <filesystem>
#include <vector>

#include "itty/grid.hh"
#include "itty/quads.hh"

class Bkgr : public itty::Grid<long> {
 private:
        itty::Atlas atlas{1024, 0, GL_NEAREST};
        itty::Quads renderer{atlas};

 public:
        // Add tiles from the given path that should contain one image to be
        // split in `w` and `h` horizontally and vertically, respectively.
        void add_tiles(const std::filesystem::path& path, size_t w, size_t h);

        // Upload all tiles for the given box.  This is usually done when the
        // player enters a new room, and the entire room is prerendered and
        // uploaded to the GPU.
        void upload(const itty::Box& room);

        // Render all uploaded tiles in the given box.
        void render(const itty::Box& view);
};

#endif // mosaic_bkgr_hh
