ge211
ge211_session.cpp
1 #include "ge211_session.h"
2 #include "ge211_error.h"
3 #include "ge211_util.h"
4 
5 #include <SDL.h>
6 #include <SDL_image.h>
7 #include <SDL_mixer.h>
8 #include <SDL_ttf.h>
9 
10 #include <clocale>
11 
12 namespace ge211 {
13 
14 namespace detail {
15 
16 Session::Session()
17 {
18  setlocale(LC_ALL, "en_US.utf8");
19 
20  int mix_flags = MIX_INIT_OGG | MIX_INIT_MP3;
21  if ((Mix_Init(mix_flags) & mix_flags) != mix_flags) {
22  info_sdl() << "Could not pre-initialize audio mixer";
23  }
24 
25  if (SDL_Init(SDL_INIT_VIDEO) < 0) {
26  fatal_sdl() << "Could not initialize graphics";
27  exit(1);
28  }
29 
30  int img_flags = IMG_INIT_JPG | IMG_INIT_PNG;
31  if (IMG_Init(img_flags) != img_flags) {
32  fatal_sdl() << "Could not initialize image loading support";
33  exit(1);
34  }
35 
36  if (TTF_Init() < 0) {
37  fatal_sdl() << "Could not initialize text handling";
38  exit(1);
39  }
40 
41  SDL_StartTextInput();
42 }
43 
44 Session::~Session()
45 {
46  SDL_StopTextInput();
47 
48  TTF_Quit();
49  IMG_Quit();
50  SDL_Quit();
51  Mix_Quit();
52 }
53 
54 } // end namespace detail
55 
56 }
The game engine namespace.
Definition: ge211.h:17