<commit_before>#include <GL/glew.h>

#include "buffer.hpp"
#include "stage.hpp"

using namespace std;

constexpr float Buffer::no_ac_params[8] = {1.0, 1.0, 1.0, 1.0, 0, 0, 0, 0};

Buffer::~Buffer() {
    int num_textures = num_textures_x*num_textures_y;
    glDeleteTextures(num_textures, buff_tex.data());
    glDeleteBuffers(1, &vbo);
}

bool Buffer::buffer_update() {
    int num_textures = num_textures_x*num_textures_y;
    glDeleteTextures(num_textures, buff_tex.data());

    setup_gl_buffer();
    return true;
}

void Buffer::getPixelInfo(stringstream& message, int x, int y) {
    int pos = y*step + x;
    message << "[";
    for(int c = 0; c < channels; ++c) {
        if(type == Buffer::BufferType::Float32) {
            float fpix = reinterpret_cast<float*>(buffer)[pos+c];
            message << fpix;
        }
        else if(type == Buffer::BufferType::UnsignedByte) {
            message << buffer[pos+c];
        }
        else if(type == Buffer::BufferType::Short) {
            short fpix = reinterpret_cast<short*>(buffer)[pos+c];
            message << fpix;
        }
        else if(type == Buffer::BufferType::UnsignedShort) {
            unsigned short fpix = reinterpret_cast<unsigned short*>(buffer)[pos+c];
            message << fpix;
        }
        else if(type == Buffer::BufferType::Int32) {
            int fpix = reinterpret_cast<int*>(buffer)[pos+c];<commit_msg>fix out of bounds, channels and chars<commit_after>#include <GL/glew.h>

#include "buffer.hpp"
#include "stage.hpp"

using namespace std;

constexpr float Buffer::no_ac_params[8] = {1.0, 1.0, 1.0, 1.0, 0, 0, 0, 0};

Buffer::~Buffer() {
    int num_textures = num_textures_x*num_textures_y;
    glDeleteTextures(num_textures, buff_tex.data());
    glDeleteBuffers(1, &vbo);
}

bool Buffer::buffer_update() {
    int num_textures = num_textures_x*num_textures_y;
    glDeleteTextures(num_textures, buff_tex.data());

    setup_gl_buffer();
    return true;
}

void Buffer::getPixelInfo(stringstream& message, int x, int y) {
    if (x < 0 || x >= buffer_width_f || y < 0 || y >= buffer_height_f) {
      message << "[out of bounds]";
      return;
    }
    int pos = channels * ( y*step + x );
    message << "[";
    for(int c = 0; c < channels; ++c) {
        if(type == Buffer::BufferType::Float32) {
            float fpix = reinterpret_cast<float*>(buffer)[pos+c];
            message << fpix;
        }
        else if(type == Buffer::BufferType::UnsignedByte) {
            short fpix = buffer[pos+c]; 
            message << fpix;
        }
        else if(type == Buffer::BufferType::Short) {
            short fpix = reinterpret_cast<short*>(buffer)[pos+c];
            message << fpix;
        }
        else if(type == Buffer::BufferType::UnsignedShort) {
            unsigned short fpix = reinterpret_cast<unsigned short*>(buffer)[pos+c];
            message << fpix;
        }
        else if(type == Buffer::BufferType::Int32) {
            int fpix = reinterpret_cast<int*>(buffer)[pos+c];
{'fraction_non_alphanumeric': 0.14893617021276595, 'fraction_numerical': 0.013297872340425532, 'mean_word_length': 2.867609254498715, 'pattern_counts': {'":': 0, '<': 39, '<?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': '3547504', 'n_tokens_mistral': 1022, 'n_tokens_neox': 997, 'n_words': 207}