Rendering Engine 0.2.0
Modular Graphics Rendering Engine | v0.2.0
Loading...
Searching...
No Matches
texture_atlas_maker.hpp
Go to the documentation of this file.
1// This file is part of the Rendering Engine project.
2// Author: Alexander Obzherin <alexanderobzherin@gmail.com>
3// Copyright (c) 2025 Alexander Obzherin
4// Distributed under the terms of the zlib License. See LICENSE.md for details.
5#pragma once
6
7#include <iostream>
8#include <unordered_map>
9#include <map>
10#include <memory>
11#include <fstream>
12#include <sstream>
13#include <boost/filesystem.hpp>
14#include "image_data.hpp"
15
16namespace rendering_engine
17{
19{
20public:
21 TextureAtlasMaker( std::map<char, ImageData> images );
22 ~TextureAtlasMaker() = default;
23
24 bool CreateTextureAtlas( std::map<char, std::pair<unsigned int, unsigned int>>& texAtlasData, ImageData& texAtlasImage );
25
26protected:
27 //Calculate cell dimensions of one cell as max width (x component) and height (y component) in pixels
28 void FindCellDimensions(unsigned int& outputWidth, unsigned int& outputHeight);
29 //Calculate number of rows and columns, trying to aim a square form
30 void CalculateGridDimensions(unsigned int& outputNumberOfColumns, unsigned int& outputNumberOfRows);
31 //Log informaion to txt file
32 void LogMetaData(const std::string& message)
33 {
34 mMetaDataOutputStream << message << std::endl;
35 }
36
37private:
39 TextureAtlasMaker operator=(TextureAtlasMaker const&);
40
41protected:
42 //container of images
43 std::map<char, ImageData> mImageCollection;
44
45 static const char* const mMetaDataFileName;
46 std::ofstream mMetaDataOutputStream;
47
49};
50
51} //namespace rendering_engine
Represents raw 2D image data stored in memory.
void FindCellDimensions(unsigned int &outputWidth, unsigned int &outputHeight)
bool CreateTextureAtlas(std::map< char, std::pair< unsigned int, unsigned int > > &texAtlasData, ImageData &texAtlasImage)
void LogMetaData(const std::string &message)
TextureAtlasMaker(std::map< char, ImageData > images)
std::map< char, ImageData > mImageCollection
void CalculateGridDimensions(unsigned int &outputNumberOfColumns, unsigned int &outputNumberOfRows)
Represents a color with red, green, blue, and alpha channels.