#include "simple.hpp" namespace simple { simple::simple() { startSDL(); } simple::~simple() { closeSDL(); } void simple::startSDL() { if (SDL_Init(SDL_INIT_VIDEO) < 0) { printf("SDL could not initialize! SDL Error: %s\n", SDL_GetError()); } else { mainWindow = SDL_CreateWindow("tbd", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 500, 500, SDL_WINDOW_SHOWN); if (mainWindow == NULL) { printf("Window could not be created! SDL Error: %s\n", SDL_GetError()); } else { mainRenderer = SDL_CreateRenderer(mainWindow, -1, SDL_RENDERER_ACCELERATED); if (mainRenderer == NULL) { printf("Renderer could not be created! SDL Error: %s\n", SDL_GetError()); } else { SDL_SetRenderDrawColor(mainRenderer, 0, 0, 0, 0); int imgFlags = IMG_INIT_PNG; if (!(IMG_Init(imgFlags) & imgFlags)) { printf("SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError()); } else { if (TTF_Init() == -1) { printf("SDL_ttf could not initialize! SDL_ttf Error: %s\n", TTF_GetError()); } } } } } } void simple::closeSDL() { SDL_DestroyRenderer(mainRenderer); SDL_DestroyWindow(mainWindow); mainWindow = NULL; TTF_Quit(); IMG_Quit(); SDL_Quit(); } }