<commit_before>#include <iostream>

#include "../glm/gtx/transform.hpp"

#include "drawable.h"

#define GET_ADDRESS(base, offset) ((char*)(base) + (offset))

using namespace std;

Drawable::Drawable() : m_idVAO(0), m_idVBO(0), m_idIBO(0), m_idTBO(0), m_shader(nullptr), m_model(1.0)
{
}

Drawable::~Drawable()
{
    glDeleteBuffers(1, &m_idVBO);
    glDeleteVertexArrays(1, &m_idVAO);
    glDeleteBuffers(1, &m_idIBO);
    glDeleteBuffers(1, &m_idTBO);
}

void Drawable::setShader(Shader* shader)
{
    m_shader = shader;
}
void Drawable::setTexture(Texture* texture)
{
    m_texture = texture;
}

void Drawable::setModel(glm::mat4 model)
{
    m_model = model;
}

const Shader* Drawable::getShader() const
{
    return m_shader;
}
const Texture* Drawable::getTexture() const
{
    return m_texture;
}

const glm::mat4& Drawable::getModel() const
{
    return m_model;
}

GLuint Drawable::getIdVAO() const
{
    return m_idVAO;
}

GLuint Drawable::getIdVBO() const
{
    return m_idVBO;
}

GLuint Drawable::getIdIBO() const
{
    return m_idIBO;
}

int Drawable::getVerticesNumber() const
{
    return m_verticesNumber;
}

int Drawable::getIndicesNumber() const
{
    return m_indicesNumber;
}

void Drawable::rotate(glm::vec3 axis, float angle)
{
    m_model = glm::rotate(m_model, angle, axis);
}

void Drawable::translate(glm::vec3 translation)
{
    m_model = glm::translate(m_model, translation);
}

void Drawable::homothetie(glm::vec3 homoth)
{
    m_model = glm::scale(m_model, homoth);
}

void Drawable::load(std::vector<glm::vec3> const &vertices, std::vector<unsigned int> const &indices, std::vector<glm::vec2> const &textures)
{
    loadVerticesVBO(vertices);
    loadTexturesVBO(textures);
    loadIndicesVBO(indices);
    //VAO
    if (glIsVertexArray(m_idVAO) == GL_TRUE)
        glDeleteVertexArrays(1, &m_idVAO);
    
    //Création et activation.
    glGenVertexArrays(1, &m_idVAO);
    glBindVertexArray(m_idVAO);

    glBindBuffer(GL_ARRAY_BUFFER, m_idVBO);
    //Identifiacation.
    glEnableVertexAttribArray(0);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
    
    glBindBuffer(GL_ARRAY_BUFFER, m_idTBO);
    //Identification.
    glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 0, 0);
    glEnableVertexAttribArray(2);

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_idIBO);
    glBindVertexArray(0);


    m_indicesNumber = indices.size() * 3 ;
    m_verticesNumber = vertices.size() * 3 ;

}
void Drawable::load(std::vector<glm::vec3> const &vertices, std::vector<unsigned int> const &indices)
{
    loadVerticesVBO(vertices);
    loadIndicesVBO(indices);
    loadVAO();
    //VAO
    if (glIsVertexArray(m_idVAO) == GL_TRUE)<commit_msg>bug fixe<commit_after>#include <iostream>

#include "../glm/gtx/transform.hpp"

#include "drawable.h"

#define GET_ADDRESS(base, offset) ((char*)(base) + (offset))

using namespace std;

Drawable::Drawable() : m_idVAO(0), m_idVBO(0), m_idIBO(0), m_idTBO(0), m_shader(nullptr), m_model(1.0)
{
}

Drawable::~Drawable()
{
    glDeleteBuffers(1, &m_idVBO);
    glDeleteVertexArrays(1, &m_idVAO);
    glDeleteBuffers(1, &m_idIBO);
    glDeleteBuffers(1, &m_idTBO);
}

void Drawable::setShader(Shader* shader)
{
    m_shader = shader;
}
void Drawable::setTexture(Texture* texture)
{
    m_texture = texture;
}

void Drawable::setModel(glm::mat4 model)
{
    m_model = model;
}

const Shader* Drawable::getShader() const
{
    return m_shader;
}
const Texture* Drawable::getTexture() const
{
    return m_texture;
}

const glm::mat4& Drawable::getModel() const
{
    return m_model;
}

GLuint Drawable::getIdVAO() const
{
    return m_idVAO;
}

GLuint Drawable::getIdVBO() const
{
    return m_idVBO;
}

GLuint Drawable::getIdIBO() const
{
    return m_idIBO;
}

int Drawable::getVerticesNumber() const
{
    return m_verticesNumber;
}

int Drawable::getIndicesNumber() const
{
    return m_indicesNumber;
}

void Drawable::rotate(glm::vec3 axis, float angle)
{
    m_model = glm::rotate(m_model, angle, axis);
}

void Drawable::translate(glm::vec3 translation)
{
    m_model = glm::translate(m_model, translation);
}

void Drawable::homothetie(glm::vec3 homoth)
{
    m_model = glm::scale(m_model, homoth);
}

void Drawable::load(std::vector<glm::vec3> const &vertices, std::vector<unsigned int> const &indices, std::vector<glm::vec2> const &textures)
{
    loadVerticesVBO(vertices);
    loadTexturesVBO(textures);
    loadIndicesVBO(indices);
    //VAO
    if (glIsVertexArray(m_idVAO) == GL_TRUE)
        glDeleteVertexArrays(1, &m_idVAO);
    
    //Création et activation.
    glGenVertexArrays(1, &m_idVAO);
    glBindVertexArray(m_idVAO);

    glBindBuffer(GL_ARRAY_BUFFER, m_idVBO);
    //Identifiacation.
    glEnableVertexAttribArray(0);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
    
    glBindBuffer(GL_ARRAY_BUFFER, m_idTBO);
    //Identification.
    glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 0, 0);
    glEnableVertexAttribArray(2);

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_idIBO);
    glBindVertexArray(0);


    m_indicesNumber = indices.size() * 3 ;
    m_verticesNumber = vertices.size() * 3 ;

}
void Drawable::load(std::vector<glm::vec3> const &vertices, std::vector<unsigned int> const &indices)
{
    loadVerticesVBO(vertices);
    loadIndicesVBO(indices);
    //VAO
    if (glIsVertexArray(m_idVAO) == GL_TRUE)
{'fraction_non_alphanumeric': 0.13902439024390245, 'fraction_numerical': 0.012382739212007506, 'mean_word_length': 4.738428417653391, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7620343', 'n_tokens_mistral': 2063, 'n_tokens_neox': 2073, 'n_words': 357}