<commit_before>/*
 * Window.cpp
 *
 *  Created on: 6. sep. 2015
 *      Author: larso
 */

#include "Window.h"
#include <stdexcept>

namespace gui
{

Window::Window()
{
    w = 640;
    h = 480;
    isopen = false;
    win = nullptr;
    wID = 0;
    ren = nullptr;
    wflags = SDL_WINDOW_RESIZABLE;
    rflags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC;
    rindex = -1;
    title = "Window";
    widget = nullptr;
}

Window::~Window()
{
    if(ren != nullptr) SDL_DestroyRenderer(ren);
    if(win != nullptr) SDL_DestroyWindow(win);
}

bool Window::isOpen()
{
    return isopen;
}

void Window::open()
{
    if(!isopen)
    {
        win = SDL_CreateWindow(title.c_str(),
                               SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
                               w, h, wflags);
        if(win == nullptr)
        {
            throw std::runtime_error(SDL_GetError());
        }

        ren = SDL_CreateRenderer(win, rindex, rflags);
        if(ren == nullptr)
        {
            std::string error(SDL_GetError());
            SDL_DestroyWindow(win);
            throw std::runtime_error(error);
        }

        isopen = true;
        wID = SDL_GetWindowID(win);
    }
}<commit_msg>Alpha blending enabled for renderer in window.<commit_after>/*
 * Window.cpp
 *
 *  Created on: 6. sep. 2015
 *      Author: larso
 */

#include "Window.h"
#include <stdexcept>

namespace gui
{

Window::Window()
{
    w = 640;
    h = 480;
    isopen = false;
    win = nullptr;
    wID = 0;
    ren = nullptr;
    wflags = SDL_WINDOW_RESIZABLE;
    rflags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC;
    rindex = -1;
    title = "Window";
    widget = nullptr;
}

Window::~Window()
{
    if(ren != nullptr) SDL_DestroyRenderer(ren);
    if(win != nullptr) SDL_DestroyWindow(win);
}

bool Window::isOpen()
{
    return isopen;
}

void Window::open()
{
    if(!isopen)
    {
        win = SDL_CreateWindow(title.c_str(),
                               SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
                               w, h, wflags);
        if(win == nullptr)
        {
            throw std::runtime_error(SDL_GetError());
        }

        ren = SDL_CreateRenderer(win, rindex, rflags);
        if(ren == nullptr)
        {
            std::string error(SDL_GetError());
            SDL_DestroyWindow(win);
            throw std::runtime_error(error);
        }

        isopen = true;
        wID = SDL_GetWindowID(win);
        SDL_SetRenderDrawBlendMode(ren, SDL_BLENDMODE_BLEND);
    }
}
{'fraction_non_alphanumeric': 0.12220039292730844, 'fraction_numerical': 0.010216110019646365, 'mean_word_length': 2.0898058252427183, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5061741', 'n_tokens_mistral': 925, 'n_tokens_neox': 858, 'n_words': 166}