Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
Loading...
Searching...
No Matches
TextureLoadData.h
1#pragma once
2
3#include <vector>
4
5namespace EngineCore {
17 TextureLoadData(std::vector<unsigned char> imageData, int width, int height, int channels) :
18 width(width),
21 imageData(std::move(imageData))
22 {
23
24 }
25
26 int width;
27 int height;
29 std::vector<unsigned char> imageData;
30
34 bool operator==(const TextureLoadData& other) const {
35 return width == other.width &&
36 height == other.height &&
37 channels == other.channels &&
38 imageData == other.imageData;
39 }
40 };
41}
42
43namespace std {
44
45 template <>
49 struct hash<EngineCore::TextureLoadData> {
53 std::size_t operator()(const EngineCore::TextureLoadData& tex) const {
54 std::size_t seed = 0;
55
56 // Hash the integral members
57 seed ^= std::hash<int>()(tex.width) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
58 seed ^= std::hash<int>()(tex.height) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
59 seed ^= std::hash<int>()(tex.channels) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
60
61 // Hash the imageData vector
62 for (const auto& byte : tex.imageData) {
63 seed ^= std::hash<unsigned char>()(byte) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
64 }
65
66 return seed;
67 }
68 };
69
70} // namespace std
STL namespace.
CPU-side image bytes and dimensions used as texture load input.
TextureLoadData(std::vector< unsigned char > imageData, int width, int height, int channels)
Creates texture load data by taking ownership of image bytes.
bool operator==(const TextureLoadData &other) const
Compares dimensions, channel count, and image bytes.
int height
Image height in pixels.
int width
Image width in pixels.
int channels
Number of channels per pixel.
std::vector< unsigned char > imageData
Pixel bytes.
std::size_t operator()(const EngineCore::TextureLoadData &tex) const
Hashes dimensions, channel count, and image bytes.