Rendering Engine 0.2.0
Modular Graphics Rendering Engine | v0.2.0
Loading...
Searching...
No Matches
texture_atlas_maker_tests.cpp
Go to the documentation of this file.
1#include <stdio.h>
2#include <cstdint>
3#include "gtest/gtest.h"
4
7
8using ::testing::EmptyTestEventListener;
9using ::testing::InitGoogleTest;
10using ::testing::Test;
11using ::testing::TestEventListeners;
12using ::testing::TestInfo;
13using ::testing::TestPartResult;
14using ::testing::TestSuite;
15using ::testing::UnitTest;
16
17using namespace rendering_engine;
18
19TEST(ImageDataTest, TextureAtlasMaker)
20{
21 ImageData image1(10U, 10U);
22 image1.Fill(Color(255, 0, 0, 255));
23
24 ImageData image2(5U, 5U);
25 image2.Fill(Color(0, 255, 0, 255));
26
27 ImageData image3(2U, 2U);
28 image3.Fill(Color(0, 0, 255, 255));
29
30 std::map<char, ImageData> imageCollection;
31
32 imageCollection.emplace('A', image1);
33 imageCollection.emplace('B', image2);
34 imageCollection.emplace('C', image3);
35
36 TextureAtlasMaker texAtlasMaker( imageCollection );
37
38 ImageData atlasImage;
39 std::map<char, std::pair<unsigned int, unsigned int>> texAtlasData;
40
41 bool const result = texAtlasMaker.CreateTextureAtlas(texAtlasData, atlasImage);
42 if( result )
43 {
44 atlasImage.WritePngFile("TestTextureAtlas.png");
45 }
46
47 EXPECT_TRUE(result);
48}
Represents raw 2D image data stored in memory.
void Fill(Color color)
Fills the image with a solid color.
void WritePngFile(char const *filename)
Writes the image data to a PNG file.
bool CreateTextureAtlas(std::map< char, std::pair< unsigned int, unsigned int > > &texAtlasData, ImageData &texAtlasImage)
Represents a color with red, green, blue, and alpha channels.
TEST(ImageDataTest, TextureAtlasMaker)