<commit_before>#include <vector>
#include <cstring>
#include <GL/glew.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include "shader.hpp"
#include "texture.hpp"
#include "text2D.hpp"

GLuint Text2DTextureID;              // Texture containing the font
GLuint Text2DVertexBufferID;         // Buffer containing the vertices
GLuint Text2DUVBufferID;             //                       UVs
GLuint Text2DShaderID;               // Program used to disaply the text
GLuint vertexPosition_screenspaceID; // Location of the program's "vertexPosition_screenspace" attribute
GLuint vertexUVID;                   // Location of the program's "vertexUV" attribute
GLuint Text2DUniformID;              // Location of the program's texture attribute
GLuint screen_width_uniform_ID;      // Location of the program's window width uniform.
GLuint screen_height_uniform_ID;     // Location of the program's window height uniform.

void initText2D(GLuint screen_width, GLuint screen_height, const char *texturePath, const char *char_font_texture_file_format)
{
    // Initialize texture
    if ((strcmp(char_font_texture_file_format, "bmp") == 0) || (strcmp(char_font_texture_file_format, "BMP") == 0))
    {
        Text2DTextureID = loadBMP_custom(texturePath);
    }
    else if ((strcmp(char_font_texture_file_format, "dds") == 0) || (strcmp(char_font_texture_file_format, "DDS") == 0))
    {
        Text2DTextureID = loadDDS(texturePath);
    }

    // Initialize VBO
    glGenBuffers(1, &Text2DVertexBufferID);
    glGenBuffers(1, &Text2DUVBufferID);

    // Initialize Shader
    Text2DShaderID = LoadShaders("TextVertexShader.vertexshader", "TextVertexShader.fragmentshader");

    // Get a handle for our buffers
    vertexPosition_screenspaceID = glGetAttribLocation(Text2DShaderID, "vertexPosition_screenspace");
    vertexUVID = glGetAttribLocation(Text2DShaderID, "vertexUV");

    // Initialize uniforms' IDs
    Text2DUniformID = glGetUniformLocation(Text2DShaderID, "myTextureSampler");

    // Initialize uniform window width.
    screen_width_uniform_ID = glGetUniformLocation(Text2DShaderID, "screen_width");
    glUniform1i(screen_width_uniform_ID, screen_width);

    // Initialize uniform window height.
    screen_height_uniform_ID = glGetUniformLocation(Text2DShaderID, "screen_height");
    glUniform1i(screen_height_uniform_ID, screen_height);
}

void printText2D(GLuint screen_width, GLuint screen_height, GLuint x, GLuint y, GLuint size, const char *text, const char *char_font_texture_file_format)
{
    uint32_t length = strlen(text);

    // Fill buffers
    std::vector<glm::vec2> vertices;
    std::vector<glm::vec2> UVs;
    for (uint32_t i = 0; i < length; i++)
    {
        // Print to the right side of X (so far there is no check for input length).
        // Print up and down of Y.
        glm::vec2 vertex_up_left    = glm::vec2(x + (i * size)       , y + size / 2);
        glm::vec2 vertex_up_right   = glm::vec2(x + (i * size + size), y + size / 2);
        glm::vec2 vertex_down_right = glm::vec2(x + (i * size + size), y - size / 2);
        glm::vec2 vertex_down_left  = glm::vec2(x + (i * size)       , y - size / 2);

        vertices.push_back(vertex_up_left);
        vertices.push_back(vertex_down_left);
        vertices.push_back(vertex_up_right);<commit_msg>Tulostetaan teksti annetun Y-koordinaatin yläpuolelle.<commit_after>#include <vector>
#include <cstring>
#include <GL/glew.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include "shader.hpp"
#include "texture.hpp"
#include "text2D.hpp"

GLuint Text2DTextureID;              // Texture containing the font
GLuint Text2DVertexBufferID;         // Buffer containing the vertices
GLuint Text2DUVBufferID;             //                       UVs
GLuint Text2DShaderID;               // Program used to disaply the text
GLuint vertexPosition_screenspaceID; // Location of the program's "vertexPosition_screenspace" attribute
GLuint vertexUVID;                   // Location of the program's "vertexUV" attribute
GLuint Text2DUniformID;              // Location of the program's texture attribute
GLuint screen_width_uniform_ID;      // Location of the program's window width uniform.
GLuint screen_height_uniform_ID;     // Location of the program's window height uniform.

void initText2D(GLuint screen_width, GLuint screen_height, const char *texturePath, const char *char_font_texture_file_format)
{
    // Initialize texture
    if ((strcmp(char_font_texture_file_format, "bmp") == 0) || (strcmp(char_font_texture_file_format, "BMP") == 0))
    {
        Text2DTextureID = loadBMP_custom(texturePath);
    }
    else if ((strcmp(char_font_texture_file_format, "dds") == 0) || (strcmp(char_font_texture_file_format, "DDS") == 0))
    {
        Text2DTextureID = loadDDS(texturePath);
    }

    // Initialize VBO
    glGenBuffers(1, &Text2DVertexBufferID);
    glGenBuffers(1, &Text2DUVBufferID);

    // Initialize Shader
    Text2DShaderID = LoadShaders("TextVertexShader.vertexshader", "TextVertexShader.fragmentshader");

    // Get a handle for our buffers
    vertexPosition_screenspaceID = glGetAttribLocation(Text2DShaderID, "vertexPosition_screenspace");
    vertexUVID = glGetAttribLocation(Text2DShaderID, "vertexUV");

    // Initialize uniforms' IDs
    Text2DUniformID = glGetUniformLocation(Text2DShaderID, "myTextureSampler");

    // Initialize uniform window width.
    screen_width_uniform_ID = glGetUniformLocation(Text2DShaderID, "screen_width");
    glUniform1i(screen_width_uniform_ID, screen_width);

    // Initialize uniform window height.
    screen_height_uniform_ID = glGetUniformLocation(Text2DShaderID, "screen_height");
    glUniform1i(screen_height_uniform_ID, screen_height);
}

void printText2D(GLuint screen_width, GLuint screen_height, GLuint x, GLuint y, GLuint size, const char *text, const char *char_font_texture_file_format)
{
    uint32_t length = strlen(text);

    // Fill buffers
    std::vector<glm::vec2> vertices;
    std::vector<glm::vec2> UVs;
    for (uint32_t i = 0; i < length; i++)
    {
        // Print to the right side of X (so far there is no check for input length).
        // Print up of Y.
        glm::vec2 vertex_up_left    = glm::vec2(x + (i * size)       , y + size);
        glm::vec2 vertex_up_right   = glm::vec2(x + (i * size + size), y + size);
        glm::vec2 vertex_down_right = glm::vec2(x + (i * size + size), y);
        glm::vec2 vertex_down_left  = glm::vec2(x + (i * size)       , y);

        vertices.push_back(vertex_up_left);
        vertices.push_back(vertex_down_left);
        vertices.push_back(vertex_up_right);
{'fraction_non_alphanumeric': 0.10271084337349398, 'fraction_numerical': 0.01325301204819277, 'mean_word_length': 3.61501042390549, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4499912', 'n_tokens_mistral': 2142, 'n_tokens_neox': 2114, 'n_words': 499}