39 lines
906 B
C++
39 lines
906 B
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <sophia/types.hpp>
|
|
#include <span>
|
|
#include <vulkan/vulkan.hpp>
|
|
|
|
#include "vulkan/device.hpp"
|
|
#include "vulkan/image.hpp"
|
|
|
|
namespace sophia {
|
|
|
|
/**
|
|
* A sampled, read-only RGBA8 (sRGB) image.
|
|
*
|
|
* Owned by the ResourceRegistry and addressed through a TextureHandle.
|
|
*/
|
|
class Texture {
|
|
public:
|
|
/** `pixels` is width * height tightly packed RGBA8 texels, top row first. */
|
|
Texture(Device& device, u32 width, u32 height, std::span<const u8> pixels);
|
|
~Texture();
|
|
|
|
Texture(const Texture&) = delete;
|
|
Texture& operator=(const Texture&) = delete;
|
|
|
|
const Image& getImage() const { return *this->image; }
|
|
|
|
u32 getWidth() const { return this->image->getExtent().width; }
|
|
u32 getHeight() const { return this->image->getExtent().height; }
|
|
|
|
vk::DescriptorImageInfo descriptorInfo() const;
|
|
|
|
private:
|
|
std::unique_ptr<Image> image;
|
|
};
|
|
|
|
} // namespace sophia
|