We got exr loading
This commit is contained in:
@@ -1,36 +1,73 @@
|
||||
#ifndef IMAGELOADER_H
|
||||
#define IMAGELOADER_H
|
||||
#include <filesystem>
|
||||
|
||||
#include <filesystem>
|
||||
#include <cstddef>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#include "destrum/Graphics/TextureIntent.h"
|
||||
|
||||
struct ImageData {
|
||||
ImageData() = default;
|
||||
~ImageData();
|
||||
|
||||
// move only
|
||||
ImageData(ImageData&& o) = default;
|
||||
ImageData& operator=(ImageData&& o) = default;
|
||||
// move only (CUSTOM!)
|
||||
ImageData(ImageData&& o) noexcept { *this = std::move(o); }
|
||||
|
||||
// no copies
|
||||
ImageData(const ImageData& o) = delete;
|
||||
ImageData& operator=(const ImageData& o) = delete;
|
||||
|
||||
// data
|
||||
ImageData& operator=(ImageData&& o) noexcept {
|
||||
if (this == &o) return *this;
|
||||
|
||||
// free current contents first
|
||||
this->~ImageData();
|
||||
|
||||
// steal
|
||||
pixels = o.pixels;
|
||||
hdrPixels = o.hdrPixels;
|
||||
hdr = o.hdr;
|
||||
width = o.width;
|
||||
height = o.height;
|
||||
channels = o.channels;
|
||||
comp = o.comp;
|
||||
shouldSTBFree = o.shouldSTBFree;
|
||||
shouldEXRFree = o.shouldEXRFree;
|
||||
vkFormat = o.vkFormat;
|
||||
byteSize = o.byteSize;
|
||||
|
||||
// neuter source so its destructor won't free our memory
|
||||
o.pixels = nullptr;
|
||||
o.hdrPixels = nullptr;
|
||||
o.shouldSTBFree = false;
|
||||
o.shouldEXRFree = false;
|
||||
o.hdr = false;
|
||||
o.width = o.height = o.channels = o.comp = 0;
|
||||
o.vkFormat = VK_FORMAT_UNDEFINED;
|
||||
o.byteSize = 0;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
ImageData(const ImageData&) = delete;
|
||||
ImageData& operator=(const ImageData&) = delete;
|
||||
|
||||
unsigned char* pixels{nullptr};
|
||||
float* hdrPixels{nullptr};
|
||||
bool hdr{false};
|
||||
|
||||
int width{0};
|
||||
int height{0};
|
||||
int channels{0};
|
||||
|
||||
// HDR only
|
||||
float* hdrPixels{nullptr};
|
||||
bool hdr{false};
|
||||
int comp{0};
|
||||
|
||||
bool shouldSTBFree{false};
|
||||
bool shouldEXRFree{false};
|
||||
|
||||
VkFormat vkFormat{VK_FORMAT_UNDEFINED};
|
||||
std::size_t byteSize{0};
|
||||
};
|
||||
|
||||
namespace util {
|
||||
ImageData loadImage(const std::filesystem::path& p);
|
||||
ImageData loadImage(const std::filesystem::path& p, TextureIntent intent);
|
||||
}
|
||||
|
||||
#endif //IMAGELOADER_H
|
||||
#endif // IMAGELOADER_H
|
||||
|
||||
Reference in New Issue
Block a user