From 163a0a8c93f6718d8ef0e7d0cb31eed1f8e4831e Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 21 Dec 2025 19:05:14 +0300 Subject: [PATCH] rename ImageFormat enum items --- src/coders/png.cpp | 10 +-- src/frontend/hud.cpp | 2 +- src/graphics/core/Atlas.cpp | 2 +- src/graphics/core/Batch2D.cpp | 2 +- src/graphics/core/Batch3D.cpp | 2 +- src/graphics/core/GBuffer.cpp | 2 +- src/graphics/core/ImageData.cpp | 62 +++++++++---------- src/graphics/core/ImageData.hpp | 6 +- src/graphics/core/Texture.cpp | 2 +- src/graphics/core/gl_util.hpp | 4 +- src/graphics/render/BlocksRenderer.hpp | 8 +-- src/graphics/render/MainBatch.cpp | 2 +- src/graphics/render/Skybox.cpp | 2 +- src/graphics/ui/gui_xml.cpp | 2 +- .../lua/usertypes/lua_type_canvas.cpp | 2 +- .../lua/usertypes/lua_type_heightmap.cpp | 2 +- src/window/detail/GLFWWindow.cpp | 2 +- test/world/generator/SurroundMap.cpp | 2 +- 18 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/coders/png.cpp b/src/coders/png.cpp index 7c469e32f..030844352 100644 --- a/src/coders/png.cpp +++ b/src/coders/png.cpp @@ -251,13 +251,13 @@ std::unique_ptr png::load_image(const ubyte* bytes, size_t size) { } png_read_image(pngPtr, rowPointers.get()); - ImageFormat format = ImageFormat::rgba8888; + ImageFormat format = ImageFormat::RGBA8888; switch (colorType) { case PNG_COLOR_TYPE_RGBA: - format = ImageFormat::rgba8888; + format = ImageFormat::RGBA8888; break; case PNG_COLOR_TYPE_RGB: - format = ImageFormat::rgb888; + format = ImageFormat::RGB888; break; default: png_destroy_read_struct(&pngPtr, &infoPtr, nullptr); @@ -296,7 +296,7 @@ void png::write_image(const std::string& filename, const ImageData* image) { image->getWidth(), image->getHeight(), (const ubyte*)image->getData(), - image->getFormat() == ImageFormat::rgba8888 + image->getFormat() == ImageFormat::RGBA8888 ); } @@ -306,6 +306,6 @@ util::Buffer png::encode_image(const ImageData& image) { image.getWidth(), image.getHeight(), image.getData(), - format == ImageFormat::rgba8888 + format == ImageFormat::RGBA8888 ); } diff --git a/src/frontend/hud.cpp b/src/frontend/hud.cpp index d40ab3b8e..92ff3a370 100644 --- a/src/frontend/hud.cpp +++ b/src/frontend/hud.cpp @@ -157,7 +157,7 @@ Hud::Hud(Engine& engine, LevelFrontend& frontend, Player& player) frontend(frontend), player(player), debugImgWorldGen(std::make_unique( - ImageFormat::rgba8888, WORLDGEN_IMG_SIZE, WORLDGEN_IMG_SIZE + ImageFormat::RGBA8888, WORLDGEN_IMG_SIZE, WORLDGEN_IMG_SIZE )) { contentAccess = createContentAccess(); contentAccess->setId("hud.content-access"); diff --git a/src/graphics/core/Atlas.cpp b/src/graphics/core/Atlas.cpp index d06a20b98..092d6fedf 100644 --- a/src/graphics/core/Atlas.cpp +++ b/src/graphics/core/Atlas.cpp @@ -95,7 +95,7 @@ std::unique_ptr AtlasBuilder::build(uint extrusion, bool prepare, uint ma } } - auto canvas = std::make_unique(ImageFormat::rgba8888, width, height); + auto canvas = std::make_unique(ImageFormat::RGBA8888, width, height); std::unordered_map regions; std::vector rects = packer.getResult(); for (uint i = 0; i < entries.size(); i++) { diff --git a/src/graphics/core/Batch2D.cpp b/src/graphics/core/Batch2D.cpp index b39866cef..7aa856f3f 100644 --- a/src/graphics/core/Batch2D.cpp +++ b/src/graphics/core/Batch2D.cpp @@ -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; } diff --git a/src/graphics/core/Batch3D.cpp b/src/graphics/core/Batch3D.cpp index df6fdef74..ce9f176c7 100644 --- a/src/graphics/core/Batch3D.cpp +++ b/src/graphics/core/Batch3D.cpp @@ -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; } diff --git a/src/graphics/core/GBuffer.cpp b/src/graphics/core/GBuffer.cpp index d466f1e99..aba3103fc 100644 --- a/src/graphics/core/GBuffer.cpp +++ b/src/graphics/core/GBuffer.cpp @@ -260,7 +260,7 @@ std::unique_ptr GBuffer::toImage() const { glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, data.get()); glBindTexture(GL_TEXTURE_2D, 0); return std::make_unique( - ImageFormat::rgb888, width, height, std::move(data) + ImageFormat::RGB888, width, height, std::move(data) ); } diff --git a/src/graphics/core/ImageData.cpp b/src/graphics/core/ImageData.cpp index 8a44068dc..6875d7ab9 100644 --- a/src/graphics/core/ImageData.cpp +++ b/src/graphics/core/ImageData.cpp @@ -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 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(); diff --git a/src/graphics/core/ImageData.hpp b/src/graphics/core/ImageData.hpp index 94987886e..8f4a81c60 100644 --- a/src/graphics/core/ImageData.hpp +++ b/src/graphics/core/ImageData.hpp @@ -6,8 +6,8 @@ #include 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; } }; diff --git a/src/graphics/core/Texture.cpp b/src/graphics/core/Texture.cpp index dcd29e372..d60bd2779 100644 --- a/src/graphics/core/Texture.cpp +++ b/src/graphics/core/Texture.cpp @@ -68,7 +68,7 @@ std::unique_ptr Texture::readData() { glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, data.get()); glBindTexture(GL_TEXTURE_2D, 0); return std::make_unique( - ImageFormat::rgba8888, width, height, std::move(data) + ImageFormat::RGBA8888, width, height, std::move(data) ); } diff --git a/src/graphics/core/gl_util.hpp b/src/graphics/core/gl_util.hpp index da2abfb5a..a21c8d8e9 100644 --- a/src/graphics/core/gl_util.hpp +++ b/src/graphics/core/gl_util.hpp @@ -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; } diff --git a/src/graphics/render/BlocksRenderer.hpp b/src/graphics/render/BlocksRenderer.hpp index 2006baab3..65d45f134 100644 --- a/src/graphics/render/BlocksRenderer.hpp +++ b/src/graphics/render/BlocksRenderer.hpp @@ -1,10 +1,7 @@ #pragma once -#include -#include -#include "voxels/voxel.hpp" #include "typedefs.hpp" - +#include "voxels/voxel.hpp" #include "voxels/Block.hpp" #include "voxels/Chunk.hpp" #include "voxels/VoxelsVolume.hpp" @@ -12,6 +9,9 @@ #include "commons.hpp" #include "settings.hpp" +#include +#include + template class Mesh; class Content; class Block; diff --git a/src/graphics/render/MainBatch.cpp b/src/graphics/render/MainBatch.cpp index 5b08ffe04..1a501ca15 100644 --- a/src/graphics/render/MainBatch.cpp +++ b/src/graphics/render/MainBatch.cpp @@ -16,7 +16,7 @@ MainBatch::MainBatch(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); } diff --git a/src/graphics/render/Skybox.cpp b/src/graphics/render/Skybox.cpp index 149acb108..b5c5191f2 100644 --- a/src/graphics/render/Skybox.cpp +++ b/src/graphics/render/Skybox.cpp @@ -28,7 +28,7 @@ Skybox::Skybox(uint size, Shader& shader) shader(shader), batch3d(std::make_unique(4096)) { - auto cubemap = std::make_unique(size, size, ImageFormat::rgb888); + auto cubemap = std::make_unique(size, size, ImageFormat::RGB888); uint fboid; glGenFramebuffers(1, &fboid); diff --git a/src/graphics/ui/gui_xml.cpp b/src/graphics/ui/gui_xml.cpp index 9b40c3b72..db8df0511 100644 --- a/src/graphics/ui/gui_xml.cpp +++ b/src/graphics/ui/gui_xml.cpp @@ -650,7 +650,7 @@ static std::shared_ptr read_canvas( size = element.attr("size").asVec2(); } auto image = - std::make_shared(reader.getGUI(), ImageFormat::rgba8888, size); + std::make_shared(reader.getGUI(), ImageFormat::RGBA8888, size); read_uinode(reader, element, *image); return image; } diff --git a/src/logic/scripting/lua/usertypes/lua_type_canvas.cpp b/src/logic/scripting/lua/usertypes/lua_type_canvas.cpp index a73172923..37c53abd9 100644 --- a/src/logic/scripting/lua/usertypes/lua_type_canvas.cpp +++ b/src/logic/scripting/lua/usertypes/lua_type_canvas.cpp @@ -401,7 +401,7 @@ static int l_meta_meta_call(lua::State* L) { return newuserdata( L, nullptr, - std::make_shared(ImageFormat::rgba8888, size.x, size.y) + std::make_shared(ImageFormat::RGBA8888, size.x, size.y) ); } diff --git a/src/logic/scripting/lua/usertypes/lua_type_heightmap.cpp b/src/logic/scripting/lua/usertypes/lua_type_heightmap.cpp index d65282982..9286467d3 100644 --- a/src/logic/scripting/lua/usertypes/lua_type_heightmap.cpp +++ b/src/logic/scripting/lua/usertypes/lua_type_heightmap.cpp @@ -56,7 +56,7 @@ static int l_dump(lua::State* L) { io::path file = require_string(L, 2); uint w = heightmap->getWidth(); uint h = heightmap->getHeight(); - ImageData image(ImageFormat::rgb888, w, h); + ImageData image(ImageFormat::RGB888, w, h); auto heights = heightmap->getValues(); auto raster = image.getData(); for (uint y = 0; y < h; y++) { diff --git a/src/window/detail/GLFWWindow.cpp b/src/window/detail/GLFWWindow.cpp index 074693066..a2f2a3733 100644 --- a/src/window/detail/GLFWWindow.cpp +++ b/src/window/detail/GLFWWindow.cpp @@ -561,7 +561,7 @@ public: glPixelStorei(GL_PACK_ALIGNMENT, 1); glReadPixels(0, 0, size.x, size.y, GL_RGB, GL_UNSIGNED_BYTE, data.get()); return std::make_unique( - ImageFormat::rgb888, size.x, size.y, data.release() + ImageFormat::RGB888, size.x, size.y, data.release() ); } diff --git a/test/world/generator/SurroundMap.cpp b/test/world/generator/SurroundMap.cpp index 6fb5d7ae2..45294fa99 100644 --- a/test/world/generator/SurroundMap.cpp +++ b/test/world/generator/SurroundMap.cpp @@ -46,7 +46,7 @@ void visualize(const SurroundMap& map, int mul, int max) { int ox = areaMap.getOffsetX(); int oy = areaMap.getOffsetY(); - ImageData image(ImageFormat::rgb888, w, h); + ImageData image(ImageFormat::RGB888, w, h); ubyte* bytes = image.getData(); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) {