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

#include "GUITexture.h"
#include "glm/glm.hpp"
#include "glm/ext/matrix_transform.hpp"

namespace engine {
    void GUITexture::bind() {
        texture->bind();
    }

    void GUITexture::unbind() {
        texture->unbind();
    }

    glm::mat4 GUITexture::getTransform() const {
        glm::vec2 translationNDC;
        translationNDC.x = position.x * 2.0f - 1.0f + size.x;
        translationNDC.y = 1.0f - position.y * 2.0f - size.y;

        auto matrix = glm::identity<glm::mat4>();
        matrix = glm::translate(matrix, glm::vec3( translationNDC, 0.0f));
        matrix = glm::scale(matrix, glm::vec3(size.x, size.y, 1.0f));
        return matrix;
    }
} // engine