<commit_before>#include "app.hpp"
#include "gl.hpp"
#include "gl_error.hpp"
#include "event_handler.hpp"
#include "navigation_event_handler.hpp"
#include "vao.hpp"
#include "vbo.hpp"
#include "shader.hpp"
#include "shader_program.hpp"
#include "vertex_format.hpp"
#include "default_shaders.hpp"

#include <array>
#include <iostream>
#include <SDL2/SDL.h>
#include <glm/glm.hpp>

using namespace plush;

NavigationEventHandler navEvHandler;

VAO *testVAO;
FragmentShader *testFragShader;
VertexShader *testVertShader;
ShaderProgram *testProgram;

glm::vec3 positions[] = {
    { glm::vec3(-1.0f, -1.0f, 0.0f) },
    { glm::vec3(1.0f, -1.0f, 0.0f) },
    { glm::vec3(1.0f, 1.0f, 0.0f) },
    { glm::vec3(-1.0f, 1.0f, 0.0f) }
};

glm::vec3 colors[] = {
    { glm::vec3(1.0f, 0.0f, 0.0f) },
    { glm::vec3(0.0f, 1.0f, 0.0f) },
    { glm::vec3(0.0f, 0.0f, 1.0f) },
    { glm::vec3(1.0f, 1.0f, 1.0f) }
};

short indices[] = { 0, 1, 2, 0, 1, 3, 4, 5, 6, 4, 5, 7 };

ArrayBuffer *posBuffer;
ArrayBuffer *colorBuffer;

void redrawDemo()
{
    glClearColor(0.0f, 0.0f, 0.2f, 1.0f);

    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    
    testVAO->bind();
    
    glDrawArrays(GL_TRIANGLES, 0, 3);
    //glDrawElements(GL_TRIANGLES, sizeof(testIndices), GL_UNSIGNED_SHORT, (const GLvoid*) 0);
    GLError::check("redrawDemo()");
}

static void prepareDemo()
{
    testFragShader = new FragmentShader("shaders/trivial_color.fsh");
    testVertShader = new VertexShader("shaders/trivial_coord_color.vsh");
    
    testProgram = new ShaderProgram();
    testProgram->attach(*testFragShader);
    testProgram->attach(*testVertShader);
    testProgram->link();
    
    testVAO = new VAO();
    testVAO->bind();

    posBuffer = new ArrayBuffer(GL_STATIC_DRAW);
    posBuffer->data(sizeof(positions), positions);
    colorBuffer = new ArrayBuffer(GL_STATIC_DRAW);
    colorBuffer->data(sizeof(colors), colors);
    
    GLint attr_coord = testProgram->getAttribLocation("coord");
    GLint attr_color = testProgram->getAttribLocation("color");

    GLError::check("prepareDemo: after getAttribLocation()");

    posBuffer->bind();
    glVertexAttribPointer(attr_coord, 3, GL_FLOAT, GL_FALSE, 0, reinterpret_cast<const GLvoid *>(0));

    GLError::check("prepareDemo: after glVertexAttribPointer(attr_coord, ...)");

    colorBuffer->bind();
    glVertexAttribPointer(attr_color, 3, GL_FLOAT, GL_FALSE, 0, reinterpret_cast<const GLvoid *>(0));
    
    GLError::check("prepareDemo: after glVertexAttribPointer(attr_color, ...)");
    
    glEnableVertexAttribArray(attr_coord);
    glEnableVertexAttribArray(attr_color);
    
    GLError::check("prepareDemo: after glEnableVertexAttribArray()");
    
    navEvHandler.makeCurrent();
    
    App::setRedrawFunc(redrawDemo);
}

int main(int argc, char **argv)
{
    if (!App::init())
        return 1;

    prepareDemo(); 
    App::eventLoop();
    
finish:
    App::finish();
    return 0;
}
<commit_msg>Fixed missing glUseProgram() in the test code (stupid me - wondered why everything shows in white!)<commit_after>#include "app.hpp"
#include "gl.hpp"
#include "gl_error.hpp"
#include "event_handler.hpp"
#include "navigation_event_handler.hpp"
#include "vao.hpp"
#include "vbo.hpp"
#include "shader.hpp"
#include "shader_program.hpp"
#include "vertex_format.hpp"
#include "default_shaders.hpp"

#include <array>
#include <iostream>
#include <SDL2/SDL.h>
#include <glm/glm.hpp>

using namespace plush;

NavigationEventHandler navEvHandler;

VAO *testVAO;
FragmentShader *testFragShader;
VertexShader *testVertShader;
ShaderProgram *testProgram;

glm::vec3 positions[] = {
    { glm::vec3(-1.0f, -1.0f, 0.0f) },
    { glm::vec3(1.0f, -1.0f, 0.0f) },
    { glm::vec3(1.0f, 1.0f, 0.0f) },
    
    { glm::vec3(0.5f, 0.5f, 0.0f) },
    { glm::vec3(-0.5f, 0.5f, 0.0f) },
    { glm::vec3(-0.5f, -0.5f, 0.0f) },
};

glm::vec3 colors[] = {
    { glm::vec3(1.0f, 0.0f, 0.0f) },
    { glm::vec3(0.0f, 1.0f, 0.0f) },
    { glm::vec3(0.0f, 0.0f, 1.0f) },
    { glm::vec3(1.0f, 0.0f, 0.0f) },
    { glm::vec3(0.0f, 1.0f, 0.0f) },
    { glm::vec3(0.0f, 0.0f, 1.0f) }
};

const GLuint ATTRIB_VERTEX_COORD = 0;
const GLuint ATTRIB_VERTEX_COLOR = 1;

short indices[] = { 0, 1, 2, 0, 1, 3, 4, 5, 6, 4, 5, 7 };

ArrayBuffer *posBuffer;
ArrayBuffer *colorBuffer;

void redrawDemo()
{
    glClearColor(0.0f, 0.0f, 0.2f, 1.0f);

    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    
    testVAO->bind();
    
    glDrawArrays(GL_TRIANGLES, 0, 6);
    //glDrawElements(GL_TRIANGLES, sizeof(testIndices), GL_UNSIGNED_SHORT, (const GLvoid*) 0);
    GLError::check("redrawDemo()");
}

static void prepareDemo()
{
    testFragShader = new FragmentShader("shaders/trivial_color.fsh");
    testVertShader = new VertexShader("shaders/trivial_coord_color.vsh");
    
    testProgram = new ShaderProgram();
    testProgram->attach(*testFragShader);
    testProgram->attach(*testVertShader);
    testProgram->link();
    testProgram->use();
    
    testVAO = new VAO();
    testVAO->bind();

    posBuffer = new ArrayBuffer(GL_STATIC_DRAW);
    posBuffer->data(sizeof(positions), positions);
    colorBuffer = new ArrayBuffer(GL_STATIC_DRAW);
    colorBuffer->data(sizeof(colors), colors);
    
    //GLint attr_coord = testProgram->getAttribLocation("coord");
    //GLint attr_color = testProgram->getAttribLocation("color");

    //GLError::check("prepareDemo: after getAttribLocation()");

    posBuffer->bind();
    glVertexAttribPointer(ATTRIB_VERTEX_COORD, 3, GL_FLOAT, GL_FALSE, 0, reinterpret_cast<const GLvoid *>(0));

    GLError::check("prepareDemo: after glVertexAttribPointer(attr_coord, ...)");

    colorBuffer->bind();
    glVertexAttribPointer(ATTRIB_VERTEX_COLOR, 3, GL_FLOAT, GL_FALSE, 0, reinterpret_cast<const GLvoid *>(0));

    GLError::check("prepareDemo: after glVertexAttribPointer(attr_color, ...)");
    
    glEnableVertexAttribArray(ATTRIB_VERTEX_COORD);
    glEnableVertexAttribArray(ATTRIB_VERTEX_COLOR);
    
    glVertexAttrib4f(ATTRIB_VERTEX_COLOR, 1.0f, 0.0f, 0.0f, 0.0f);
    
    GLError::check("prepareDemo: after glEnableVertexAttribArray()");
    
    navEvHandler.makeCurrent();
    
    App::setRedrawFunc(redrawDemo);
}

int main(int argc, char **argv)
{
    if (!App::init())
        return 1;

    prepareDemo(); 
    App::eventLoop();
    
finish:
    App::finish();
    return 0;
}

{'fraction_non_alphanumeric': 0.16333280831627028, 'fraction_numerical': 0.034493621042683886, 'mean_word_length': 4.125100887812752, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 38, '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': '5667075', 'n_tokens_mistral': 2564, 'n_tokens_neox': 2435, 'n_words': 422}