#include "MPFW_Atlasing.h"

int MPFW::Render::LoadTextureAtlasFromImages(std::vector<Image> images)
{
    int largestWidth = 0;
    int atlasHeight = 0;

    for (int i = 0; i < images.size(); i++) {
        if (images[i].width > largestWidth) largestWidth = images[i].width;
        atlasHeight += images[i].height;
    }


    Image atlasImage = GenImageColor(largestWidth, atlasHeight, BLANK);

    int currentImageHeight = 0;
    for (int i = 0; i < images.size(); i++) {

        ImageDraw(&atlasImage, images[i], { 0,0,(float)images[i].width, (float)images[i].height }, { 0,(float)currentImageHeight,(float)images[i].width, (float)images[i].height }, WHITE);

        currentImageHeight += images[i].height;

    }
    

    // ExportImage(atlasImage, "testatlas.png");

    return 0;




}
