<commit_before>#include "GLManager.h"

/**
 * initGL() - create and configure OpenGL resources
 *
 * @return bool true if initialization is a success
 */
bool GLManager::initGL()
{
    // success flag
    bool success = true;

    // generate program
    programID = glCreateProgram();

    // enable z-buffer face culling
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);

    // transparency
    //glEnable(GL_BLEND);
    //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    // enable vsync rate
    if (SDL_GL_SetSwapInterval(1) < 0)
        std::cout << "Swap Interval could not be set!" << std::endl;

    // vertex & fragment shaders
    vertexShader   = 0;
    fragmentShader = 0;
    ShaderLoader loader;

    // load vertex shader
    int failCount = 0;
    while (vertexShader == 0) {
        vertexShader = loader.loadShader( OsType::osConvert("shaders/phongAttenuation.vert"), programID );
        ++failCount;
        if (failCount >= 1000) {
            std::cout << "Loading vertexShader failed!" << std::endl;
            failCount = 0;
            break;
        }
    }

    // load fragment shader
    while (fragmentShader == 0) {
        fragmentShader = loader.loadShader( OsType::osConvert("shaders/phongAttenuation.frag"), programID );
        ++failCount;
        if (failCount >= 1000) {
            std::cout << "Loading fragmentShader failed!" << std::endl;
            failCount = 0;
            break;
        }
    }

    // create VAO
    glGenVertexArrays(1, &VAO);

    // link OpenGL program
    glLinkProgram(programID);

    //Initialize clear color
    glClearColor(0.0, 0.0, 0.0, 1.0f);

    return success;
}

/**
 * initSDL() - create and configure native windowing systemDimensions
 * @return bool true if initialization is a success
 */
bool GLManager::initSDL()
{
    bool success = true;

    //Initialize SDL
    if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
        printf("SDL could not initialize! SDL Error: %s\n", SDL_GetError());
        success = false;

    //Use OpenGL 3.3 core
    } else {
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 8);

        // allow for multisampling of frame buffer
        glEnable(GL_MULTISAMPLE);

        // use native width and height of screen if possible
        SDL_Rect r;
        if (SDL_GetDisplayBounds(0, &r) == 0) {
            this->screenWidth = r.w;// * 0.85f;
            this->screenHeight = r.h;// * 0.85f;
        }

        //Create window
        window = SDL_CreateWindow("opulence v1.0",
                                   SDL_WINDOWPOS_UNDEFINED,
                                   SDL_WINDOWPOS_UNDEFINED,<commit_msg>increaed depth buffer to 24 bits<commit_after>#include "GLManager.h"

/**
 * initGL() - create and configure OpenGL resources
 *
 * @return bool true if initialization is a success
 */
bool GLManager::initGL()
{
    // success flag
    bool success = true;

    // generate program
    programID = glCreateProgram();

    // enable z-buffer face culling
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LESS);

    // transparency
    //glEnable(GL_BLEND);
    //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    // enable vsync rate
    if (SDL_GL_SetSwapInterval(1) < 0)
        std::cout << "Swap Interval could not be set!" << std::endl;

    // vertex & fragment shaders
    vertexShader   = 0;
    fragmentShader = 0;
    ShaderLoader loader;

    // load vertex shader
    int failCount = 0;
    while (vertexShader == 0) {
        vertexShader = loader.loadShader( OsType::osConvert("shaders/phongAttenuation.vert"), programID );
        ++failCount;
        if (failCount >= 1000) {
            std::cout << "Loading vertexShader failed!" << std::endl;
            failCount = 0;
            break;
        }
    }

    // load fragment shader
    while (fragmentShader == 0) {
        fragmentShader = loader.loadShader( OsType::osConvert("shaders/phongAttenuation.frag"), programID );
        ++failCount;
        if (failCount >= 1000) {
            std::cout << "Loading fragmentShader failed!" << std::endl;
            failCount = 0;
            break;
        }
    }

    // create VAO
    glGenVertexArrays(1, &VAO);

    // link OpenGL program
    glLinkProgram(programID);

    //Initialize clear color
    glClearColor(0.0, 0.0, 0.0, 1.0f);

    return success;
}

/**
 * initSDL() - create and configure native windowing systemDimensions
 * @return bool true if initialization is a success
 */
bool GLManager::initSDL()
{
    bool success = true;

    //Initialize SDL
    if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
        printf("SDL could not initialize! SDL Error: %s\n", SDL_GetError());
        success = false;

    //Use OpenGL 3.3 core
    } else {
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
        SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 8);

        // allow for multisampling of frame buffer
        glEnable(GL_MULTISAMPLE);

        // use native width and height of screen if possible
        SDL_Rect r;
        if (SDL_GetDisplayBounds(0, &r) == 0) {
            this->screenWidth = r.w;// * 0.85f;
            this->screenHeight = r.h;// * 0.85f;
        }

        //Create window
        window = SDL_CreateWindow("opulence v1.0",
                                   SDL_WINDOWPOS_UNDEFINED,
                                   SDL_WINDOWPOS_UNDEFINED,
{'fraction_non_alphanumeric': 0.10731544742542909, 'fraction_numerical': 0.015330778203632729, 'mean_word_length': 2.37570303712036, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7429145', 'n_tokens_mistral': 2031, 'n_tokens_neox': 1859, 'n_words': 428}