text: #include "Model.h"
  
  #include <cstddef>
  #include <glad/glad.h>
  
  Model* Model::InstanceEmpty = nullptr;
  
  Model::Model()
  {
      glGenBuffers(1, &m_vbo);
      glGenBuffers(1, &m_ibo);
      glGenVertexArrays(1, &m_vao);
  
      glBindVertexArray(m_vao);
      
      glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ibo);
  
      m_indices = 0;
  }
  Model::Model(const Vertex* a_vertices, const unsigned int* a_indices, unsigned int a_vertexCount, unsigned int a_indexCount)
  {
      glGenBuffers(1, &m_vbo);
      glGenBuffers(1, &m_ibo);
      glGenVertexArrays(1, &m_vao);
  
      glBindVertexArray(m_vao);
      
      glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
      glBufferData(GL_ARRAY_BUFFER, a_vertexCount * sizeof(Vertex), a_vertices, GL_STATIC_DRAW);
      
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ibo);
      glBufferData(GL_ELEMENT_ARRAY_BUFFER, a_indexCount * sizeof(unsigned int), a_indices, GL_STATIC_DRAW);
  
      glEnableVertexAttribArray(0);
      glVertexAttribPointer(0, 4, GL_FLOAT, false, sizeof(Vertex), (void*)offsetof(Vertex, Position));
      glEnableVertexAttribArray(1);
      glVertexAttribPointer(1, 3, GL_FLOAT, false, sizeof(Vertex), (void*)offsetof(Vertex, Normal));
      glEnableVertexAttribArray(2);
      glVertexAttribPointer(2, 2, GL_FLOAT, false, sizeof(Vertex), (void*)offsetof(Vertex, UV));
      glEnableVertexAttribArray(3);
      glVertexAttribPointer(3, 4, GL_FLOAT, false, sizeof(Vertex), (void*)offsetof(Vertex, Bones));
      glEnableVertexAttribArray(4);
      glVertexAttribPointer(4, 4, GL_FLOAT, false, sizeof(Vertex), (void*)offsetof(Vertex, Weights));
  
      m_indices = a_indexCount;
  }
  Model::~Model()
  {
      glDeleteBuffers(1, &m_vbo);
      glDeleteBuffers(1, &m_ibo);
      glDeleteVertexArrays(1, &m_vao);
  }
  
  void Model::Init()
  {
      if (InstanceEmpty == nullptr)
      {
          InstanceEmpty = new Model();
      }
  }
  void Model::Destroy()
  {
      if (InstanceEmpty != nullptr)
      {
          delete InstanceEmpty;
          InstanceEmpty = nullptr;
      }
  }