//
// Created by sebastian on 06.08.26.
//

#include "QuadFactory.h"

std::shared_ptr<engine::SimpleTexturedMesh> engine::QuadFactory::createFullScreenQuad() {
    // pos.xy in NDC, uv.xy
    std::vector<float> vertices = {
        -1,-1,
      1,-1,
      1, 1,

      1, 1,
     -1, 1,
     -1,-1
    };
    std::vector<unsigned int> indices = { 0, 1, 2,  2, 3, 0 };

    auto vao = Vao::create();
    std::vector<std::unique_ptr<Attribute>> attribs;
    attribs.push_back(std::make_unique<Vec2Attribute>(0)); // position
    vao->initDataFeed(vertices.data(), vertices.size() * sizeof(float), GL_STATIC_DRAW, std::move(attribs));
    vao->createIndexBuffer(indices.data(), indices.size());
    vao->unbind();

    return std::make_shared<engine::SimpleTexturedMesh>(std::move(vao), 4);
}
