49 lines
963 B
C++
49 lines
963 B
C++
|
|
#pragma once
|
|
|
|
#if !defined(SDL_GPU_TEST_PRIVATE_TEXTURE_PACKER_PACKER_HPP_INCLUDED)
|
|
#define SDL_GPU_TEST_PRIVATE_TEXTURE_PACKER_PACKER_HPP_INCLUDED 1
|
|
|
|
#include <filesystem>
|
|
#include <vector>
|
|
|
|
namespace fs = std::filesystem;
|
|
|
|
namespace sdl_gpu_test
|
|
{
|
|
struct FreeDeleter
|
|
{
|
|
void operator()(void* ptr) noexcept
|
|
{
|
|
std::free(ptr);
|
|
}
|
|
};
|
|
|
|
class Packer
|
|
{
|
|
private:
|
|
struct Pixel
|
|
{
|
|
std::uint8_t r;
|
|
std::uint8_t g;
|
|
std::uint8_t b;
|
|
std::uint8_t a;
|
|
};
|
|
struct ImageData
|
|
{
|
|
std::string name;
|
|
std::unique_ptr<Pixel[], FreeDeleter> data;
|
|
unsigned width;
|
|
unsigned height;
|
|
};
|
|
|
|
std::vector<ImageData> mImages;
|
|
public:
|
|
void addImage(std::string name, const fs::path& path);
|
|
void addImageList(const fs::path& path);
|
|
void pack(const fs::path& outputPath);
|
|
};
|
|
} // namespace sdl_gpu_test
|
|
|
|
#endif // !defined(SDL_GPU_TEST_PRIVATE_TEXTURE_PACKER_PACKER_HPP_INCLUDED)
|