I am currently learning cg, and I have to load some textures. I tried using stb_images and it works fine but when i load an image inside the memory it takes up too much space.
I am using a small jpg(512*512, 154kb), but if I load it 10 times, it will occupy around 12 MB of memory. (I use visual studio diagnostic tool to check process memory)
How could I eliminate this wast amount of memory usage.
struct Image {
int width, height, bpp;
unsigned char* rgba;
Image(const std::string& filePath) {
rgba = stbi_load(filePath.c_str(), &width, &height, &bpp, 4);
}
~Image() {
stbi_image_free(rgba);
}
};
std::vector<Image> images;
images.reserve(10);
for (int i = 0; i < 10; ++i)
images.emplace_back("res/textures/image.jpg");