#include "gfx/gl_loader.h"
#include "gfx/fullscreen_quad.h"

namespace fn::gfx {

void quad_init(Quad& q) {
    glGenVertexArrays(1, &q.vao);
    glGenBuffers(1, &q.vbo);
    // Vertex shader generates positions from gl_VertexID — VBO stays empty.
    glBindVertexArray(q.vao);
    glBindBuffer(GL_ARRAY_BUFFER, q.vbo);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindVertexArray(0);
}

void quad_draw(const Quad& q) {
    glBindVertexArray(q.vao);
    glDrawArrays(GL_TRIANGLES, 0, 6);
    glBindVertexArray(0);
}

void quad_destroy(Quad& q) {
    if (q.vao) { glDeleteVertexArrays(1, &q.vao); q.vao = 0; }
    if (q.vbo) { glDeleteBuffers(1, &q.vbo); q.vbo = 0; }
}

} // namespace fn::gfx
