<commit_before>#ifndef SRC_GRAPHICS_VERTEX_BUFFER_H_

#define SRC_GRAPHICS_VERTEX_BUFFER_H_

#include <vector>
#include "./gl.h"

namespace Graphics
{

/**
 * \brief OpenGL Buffer for float data
 *
 * Automatically generates and binds a new OpenGL Buffer Object
 * for the defined data vector
 *
 * @see VertexArray
 */
class VertexBuffer
{
 public:
  VertexBuffer(Gl *gl, std::vector<float> data, int elementSize)
    : gl(gl), elementSize(elementSize)
  {
    gl->glGenBuffers(1, &id);
    gl->glBindBuffer(GL_ARRAY_BUFFER, id);
    gl->glBufferData(GL_ARRAY_BUFFER, data.size() * sizeof(float), &data[0],
                     GL_STATIC_DRAW);
    size = data.size();
  }

  ~VertexBuffer()
  {
    gl->glBindBuffer(GL_ARRAY_BUFFER, 0);
    gl->glDeleteBuffers(1, &id);
  }

  void bind()
  {
    gl->glBindBuffer(GL_ARRAY_BUFFER, id);
  }

  size_t getSize()
  {
    return size;
  }

  int getElementSize()
  {
    return elementSize;
  }

 private:
  Gl *gl;
  GLuint id;

  size_t size;
  int elementSize;
};<commit_msg>Add VertexBuffer constructor which just reserves memory and a method to update the data.<commit_after>#ifndef SRC_GRAPHICS_VERTEX_BUFFER_H_

#define SRC_GRAPHICS_VERTEX_BUFFER_H_

#include <vector>
#include "./gl.h"

namespace Graphics
{

/**
 * \brief OpenGL Buffer for float data
 *
 * Automatically generates and binds a new OpenGL Buffer Object
 * for the defined data vector
 *
 * @see VertexArray
 */
class VertexBuffer
{
 public:
  VertexBuffer(Gl *gl, std::vector<float> data, int elementSize)
    : gl(gl), elementSize(elementSize)
  {
    gl->glGenBuffers(1, &id);
    gl->glBindBuffer(GL_ARRAY_BUFFER, id);
    gl->glBufferData(GL_ARRAY_BUFFER, data.size() * sizeof(float), &data[0],
                     GL_STATIC_DRAW);
    size = data.size();
  }

  VertexBuffer(Gl *gl, int elementCount, int elementSize)
    : gl(gl), size(elementCount), elementSize(elementSize)
  {
    gl->glGenBuffers(1, &id);
    gl->glBindBuffer(GL_ARRAY_BUFFER, id);
    gl->glBufferData(GL_ARRAY_BUFFER, elementCount * sizeof(float), nullptr,
                     GL_DYNAMIC_DRAW);
  }

  ~VertexBuffer()
  {
    gl->glBindBuffer(GL_ARRAY_BUFFER, 0);
    gl->glDeleteBuffers(1, &id);
  }

  void bind()
  {
    gl->glBindBuffer(GL_ARRAY_BUFFER, id);
  }

  void update(std::vector<float> data)
  {
    bind();
    gl->glBufferData(GL_ARRAY_BUFFER, data.size() * sizeof(float), &data[0],
                     GL_DYNAMIC_DRAW);
  }

  size_t getSize()
  {
    return size;
  }

  int getElementSize()
  {
    return elementSize;
  }

 private:
  Gl *gl;
  GLuint id;

  size_t size;
  int elementSize;
};
{'fraction_non_alphanumeric': 0.1241405653170359, 'fraction_numerical': 0.0038197097020626434, 'mean_word_length': 3.3360927152317883, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 24, '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': '6173965', 'n_tokens_mistral': 960, 'n_tokens_neox': 924, 'n_words': 200}