-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.cpp
31 lines (24 loc) · 1011 Bytes
/
Game.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "Game.h"
Game* Game::instance = NULL;
/// \brief Initializes SDL and other extensions.
///
Game::Game():winWidth(640), winHeight(475), renderer(NULL), window(NULL)
{
if(SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO ) != 0) throw GameException("SDL Initialization failure");
if(IMG_Init(IMG_INIT_PNG) != IMG_INIT_PNG) throw GameException("SDL_image initialization failure.");
if(TTF_Init() != 0) throw GameException("SDL_TTF initialization failure.");
window = SDL_CreateWindow("Game of Go", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, winWidth, winHeight, SDL_WINDOW_SHOWN);
if(window == NULL) throw GameException("Window creation failure.");
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
if(renderer == NULL) throw GameException("Renderer creation failure.");
}
/// \brief Closes SDL and other extensions.
///
Game::~Game()
{
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
IMG_Quit();
TTF_Quit();
}