Program Listing for File cpu_texture.hpp¶
↰ Return to documentation for file (inexor/vulkan-renderer/wrapper/cpu_texture.hpp
)
#pragma once
#include <string>
#include <stb_image.h>
namespace inexor::vulkan_renderer::wrapper {
class CpuTexture {
std::string m_name;
int m_texture_width{0};
int m_texture_height{0};
int m_texture_channels{0};
int m_mip_levels{0};
stbi_uc *m_texture_data{nullptr};
void generate_error_texture_data();
public:
CpuTexture();
CpuTexture(const std::string &file_name, std::string name);
CpuTexture(const CpuTexture &) = delete;
CpuTexture(CpuTexture &&) noexcept;
~CpuTexture();
CpuTexture &operator=(const CpuTexture &) = delete;
CpuTexture &operator=(CpuTexture &&) = default;
[[nodiscard]] const std::string &name() const {
return m_name;
}
[[nodiscard]] int width() const {
return m_texture_width;
}
[[nodiscard]] int height() const {
return m_texture_height;
}
[[nodiscard]] int channels() const {
return m_texture_channels;
}
[[nodiscard]] int mip_levels() const {
return m_mip_levels;
}
[[nodiscard]] stbi_uc *data() const {
return m_texture_data;
}
[[nodiscard]] std::size_t data_size() const {
// TODO: We will need to update this once we fully support mip levels.
return static_cast<std::size_t>(m_texture_width) * static_cast<std::size_t>(m_texture_height) *
static_cast<std::size_t>(m_texture_channels);
}
};
} // namespace inexor::vulkan_renderer::wrapper