mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-09 13:01:49 +00:00
rename ImageFormat enum items
This commit is contained in:
parent
1940fa7fa4
commit
163a0a8c93
18 changed files with 58 additions and 58 deletions
|
|
@ -95,7 +95,7 @@ std::unique_ptr<Atlas> AtlasBuilder::build(uint extrusion, bool prepare, uint ma
|
|||
}
|
||||
}
|
||||
|
||||
auto canvas = std::make_unique<ImageData>(ImageFormat::rgba8888, width, height);
|
||||
auto canvas = std::make_unique<ImageData>(ImageFormat::RGBA8888, width, height);
|
||||
std::unordered_map<std::string, UVRegion> regions;
|
||||
std::vector<rectangle> rects = packer.getResult();
|
||||
for (uint i = 0; i < entries.size(); i++) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ Batch2D::Batch2D(size_t capacity) : capacity(capacity), color(1.0f){
|
|||
const ubyte pixels[] = {
|
||||
0xFF, 0xFF, 0xFF, 0xFF
|
||||
};
|
||||
ImageData image(ImageFormat::rgba8888, 1, 1, pixels);
|
||||
ImageData image(ImageFormat::RGBA8888, 1, 1, pixels);
|
||||
blank = Texture::from(&image);
|
||||
currentTexture = nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ Batch3D::Batch3D(size_t capacity)
|
|||
const ubyte pixels[] = {
|
||||
255, 255, 255, 255,
|
||||
};
|
||||
ImageData image(ImageFormat::rgba8888, 1, 1, pixels);
|
||||
ImageData image(ImageFormat::RGBA8888, 1, 1, pixels);
|
||||
blank = Texture::from(&image);
|
||||
currentTexture = nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ std::unique_ptr<ImageData> GBuffer::toImage() const {
|
|||
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, data.get());
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
return std::make_unique<ImageData>(
|
||||
ImageFormat::rgb888, width, height, std::move(data)
|
||||
ImageFormat::RGB888, width, height, std::move(data)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ ImageData::ImageData(ImageFormat format, uint width, uint height)
|
|||
: format(format), width(width), height(height) {
|
||||
size_t pixsize;
|
||||
switch (format) {
|
||||
case ImageFormat::rgb888: pixsize = 3; break;
|
||||
case ImageFormat::rgba8888: pixsize = 4; break;
|
||||
case ImageFormat::RGB888: pixsize = 3; break;
|
||||
case ImageFormat::RGBA8888: pixsize = 4; break;
|
||||
default:
|
||||
throw std::runtime_error("format is not supported");
|
||||
}
|
||||
|
|
@ -27,8 +27,8 @@ ImageData::ImageData(ImageFormat format, uint width, uint height, const ubyte* d
|
|||
: format(format), width(width), height(height) {
|
||||
size_t pixsize;
|
||||
switch (format) {
|
||||
case ImageFormat::rgb888: pixsize = 3; break;
|
||||
case ImageFormat::rgba8888: pixsize = 4; break;
|
||||
case ImageFormat::RGB888: pixsize = 3; break;
|
||||
case ImageFormat::RGBA8888: pixsize = 4; break;
|
||||
default:
|
||||
throw std::runtime_error("format is not supported");
|
||||
}
|
||||
|
|
@ -40,9 +40,9 @@ ImageData::~ImageData() = default;
|
|||
|
||||
void ImageData::flipX() {
|
||||
switch (format) {
|
||||
case ImageFormat::rgb888:
|
||||
case ImageFormat::rgba8888: {
|
||||
uint size = (format == ImageFormat::rgba8888) ? 4 : 3;
|
||||
case ImageFormat::RGB888:
|
||||
case ImageFormat::RGBA8888: {
|
||||
uint size = (format == ImageFormat::RGBA8888) ? 4 : 3;
|
||||
for (uint y = 0; y < height; y++) {
|
||||
for (uint x = 0; x < width / 2; x++) {
|
||||
for (uint c = 0; c < size; c++) {
|
||||
|
|
@ -62,9 +62,9 @@ void ImageData::flipX() {
|
|||
|
||||
void ImageData::flipY() {
|
||||
switch (format) {
|
||||
case ImageFormat::rgb888:
|
||||
case ImageFormat::rgba8888: {
|
||||
uint size = (format == ImageFormat::rgba8888) ? 4 : 3;
|
||||
case ImageFormat::RGB888:
|
||||
case ImageFormat::RGBA8888: {
|
||||
uint size = (format == ImageFormat::RGBA8888) ? 4 : 3;
|
||||
for (uint y = 0; y < height/2; y++) {
|
||||
for (uint x = 0; x < width; x++) {
|
||||
for (uint c = 0; c < size; c++) {
|
||||
|
|
@ -87,8 +87,8 @@ void ImageData::blit(const ImageData& image, int x, int y) {
|
|||
blitMatchingFormat(image, x, y);
|
||||
return;
|
||||
}
|
||||
if (format == ImageFormat::rgba8888 &&
|
||||
image.format == ImageFormat::rgb888) {
|
||||
if (format == ImageFormat::RGBA8888 &&
|
||||
image.format == ImageFormat::RGB888) {
|
||||
blitRGB_on_RGBA(image, x, y);
|
||||
return;
|
||||
}
|
||||
|
|
@ -188,10 +188,10 @@ static void draw_line(ImageData& image, int x1, int y1, int x2, int y2, const gl
|
|||
|
||||
void ImageData::drawLine(int x1, int y1, int x2, int y2, const glm::ivec4& color) {
|
||||
switch (format) {
|
||||
case ImageFormat::rgb888:
|
||||
case ImageFormat::RGB888:
|
||||
draw_line<3>(*this, x1, y1, x2, y2, color);
|
||||
break;
|
||||
case ImageFormat::rgba8888:
|
||||
case ImageFormat::RGBA8888:
|
||||
draw_line<4>(*this, x1, y1, x2, y2, color);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -223,10 +223,10 @@ static void draw_rect(ImageData& image, int dstX, int dstY, int width, int heigh
|
|||
|
||||
void ImageData::drawRect(int x, int y, int width, int height, const glm::ivec4& color) {
|
||||
switch (format) {
|
||||
case ImageFormat::rgb888:
|
||||
case ImageFormat::RGB888:
|
||||
draw_rect<3>(*this, x, y, width, height, color);
|
||||
break;
|
||||
case ImageFormat::rgba8888:
|
||||
case ImageFormat::RGBA8888:
|
||||
draw_rect<4>(*this, x, y, width, height, color);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -260,8 +260,8 @@ void ImageData::blitRGB_on_RGBA(const ImageData& image, int x, int y) {
|
|||
void ImageData::blitMatchingFormat(const ImageData& image, int x, int y) {
|
||||
uint comps;
|
||||
switch (format) {
|
||||
case ImageFormat::rgb888: comps = 3; break;
|
||||
case ImageFormat::rgba8888: comps = 4; break;
|
||||
case ImageFormat::RGB888: comps = 3; break;
|
||||
case ImageFormat::RGBA8888: comps = 4; break;
|
||||
default:
|
||||
throw std::runtime_error("only unsigned byte formats supported");
|
||||
}
|
||||
|
|
@ -295,8 +295,8 @@ void ImageData::blitMatchingFormat(const ImageData& image, int x, int y) {
|
|||
void ImageData::extrude(int x, int y, int w, int h) {
|
||||
uint comps;
|
||||
switch (format) {
|
||||
case ImageFormat::rgb888: comps = 3; break;
|
||||
case ImageFormat::rgba8888: comps = 4; break;
|
||||
case ImageFormat::RGB888: comps = 3; break;
|
||||
case ImageFormat::RGBA8888: comps = 4; break;
|
||||
default:
|
||||
throw std::runtime_error("only unsigned byte formats supported");
|
||||
}
|
||||
|
|
@ -431,8 +431,8 @@ static void check_matching(const ImageData& a, const ImageData& b) {
|
|||
void ImageData::mulColor(const glm::ivec4& color) {
|
||||
uint comps;
|
||||
switch (format) {
|
||||
case ImageFormat::rgb888: comps = 3; break;
|
||||
case ImageFormat::rgba8888: comps = 4; break;
|
||||
case ImageFormat::RGB888: comps = 3; break;
|
||||
case ImageFormat::RGBA8888: comps = 4; break;
|
||||
default:
|
||||
throw std::runtime_error("only unsigned byte formats supported");
|
||||
}
|
||||
|
|
@ -453,8 +453,8 @@ void ImageData::addColor(const ImageData& other, int multiplier) {
|
|||
|
||||
uint comps;
|
||||
switch (format) {
|
||||
case ImageFormat::rgb888: comps = 3; break;
|
||||
case ImageFormat::rgba8888: comps = 4; break;
|
||||
case ImageFormat::RGB888: comps = 3; break;
|
||||
case ImageFormat::RGBA8888: comps = 4; break;
|
||||
default:
|
||||
throw std::runtime_error("only unsigned byte formats supported");
|
||||
}
|
||||
|
|
@ -473,8 +473,8 @@ void ImageData::addColor(const ImageData& other, int multiplier) {
|
|||
void ImageData::extend(int newWidth, int newHeight) {
|
||||
size_t comps;
|
||||
switch (format) {
|
||||
case ImageFormat::rgb888: comps = 3; break;
|
||||
case ImageFormat::rgba8888: comps = 4; break;
|
||||
case ImageFormat::RGB888: comps = 3; break;
|
||||
case ImageFormat::RGBA8888: comps = 4; break;
|
||||
default:
|
||||
throw std::runtime_error("only unsigned byte formats supported");
|
||||
}
|
||||
|
|
@ -499,8 +499,8 @@ void ImageData::extend(int newWidth, int newHeight) {
|
|||
void ImageData::addColor(const glm::ivec4& color, int multiplier) {
|
||||
uint comps;
|
||||
switch (format) {
|
||||
case ImageFormat::rgb888: comps = 3; break;
|
||||
case ImageFormat::rgba8888: comps = 4; break;
|
||||
case ImageFormat::RGB888: comps = 3; break;
|
||||
case ImageFormat::RGBA8888: comps = 4; break;
|
||||
default:
|
||||
throw std::runtime_error("only unsigned byte formats supported");
|
||||
}
|
||||
|
|
@ -521,8 +521,8 @@ void ImageData::mulColor(const ImageData& other) {
|
|||
|
||||
uint comps;
|
||||
switch (format) {
|
||||
case ImageFormat::rgb888: comps = 3; break;
|
||||
case ImageFormat::rgba8888: comps = 4; break;
|
||||
case ImageFormat::RGB888: comps = 3; break;
|
||||
case ImageFormat::RGBA8888: comps = 4; break;
|
||||
default:
|
||||
throw std::runtime_error("only unsigned byte formats supported");
|
||||
}
|
||||
|
|
@ -541,7 +541,7 @@ void ImageData::mulColor(const ImageData& other) {
|
|||
|
||||
std::unique_ptr<ImageData> add_atlas_margins(ImageData* image, int grid_size) {
|
||||
// RGBA is only supported
|
||||
assert(image->getFormat() == ImageFormat::rgba8888);
|
||||
assert(image->getFormat() == ImageFormat::RGBA8888);
|
||||
assert(image->getWidth() == image->getHeight());
|
||||
|
||||
int srcwidth = image->getWidth();
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
#include <memory>
|
||||
|
||||
enum class ImageFormat {
|
||||
rgb888,
|
||||
rgba8888
|
||||
RGB888,
|
||||
RGBA8888
|
||||
};
|
||||
|
||||
class ImageData {
|
||||
|
|
@ -57,7 +57,7 @@ public:
|
|||
}
|
||||
|
||||
size_t getDataSize() const {
|
||||
size_t channels = 3 + (format == ImageFormat::rgba8888);
|
||||
size_t channels = 3 + (format == ImageFormat::RGBA8888);
|
||||
return width * height * channels;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ std::unique_ptr<ImageData> Texture::readData() {
|
|||
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, data.get());
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
return std::make_unique<ImageData>(
|
||||
ImageFormat::rgba8888, width, height, std::move(data)
|
||||
ImageFormat::RGBA8888, width, height, std::move(data)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
namespace gl {
|
||||
inline GLenum to_glenum(ImageFormat imageFormat) {
|
||||
switch (imageFormat) {
|
||||
case ImageFormat::rgb888: return GL_RGB;
|
||||
case ImageFormat::rgba8888: return GL_RGBA;
|
||||
case ImageFormat::RGB888: return GL_RGB;
|
||||
case ImageFormat::RGBA8888: return GL_RGBA;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue