forked from jjuhl/Blocks-and-Bombs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cc
40 lines (35 loc) · 971 Bytes
/
main.cc
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
30
31
32
33
34
35
36
37
38
39
40
/*
* Copyright © 2011 by Jesper Juhl
* Licensed under the terms of the GNU General Public License (GPL) version 2.
*/
#include <iostream>
#include <cstdlib>
#include <SDL.h>
#include <libconfig.h++>
#include "bbengine.hh"
#include "config.h"
#include "except.hh"
// ensure that SDL is always shut down properly, no matter how we terminate
class SDLWrap {
public:
SDLWrap(Uint32 sdl_flags)
{
if (SDL_Init(sdl_flags))
throw Exception("Unable to initialize SDL: "
+ std::string(SDL_GetError()));
}
~SDLWrap() { SDL_Quit(); }
};
int main(int argc, char* argv[])
{
SDLWrap sdl(SDL_INIT_TIMER|SDL_INIT_VIDEO);
SDL_WM_SetCaption("Blocks and Bombs", "Blocks and Bombs");
// Setting the icon must happen before SDL_SetVideoMode
SDL_Surface* icon = SDL_LoadBMP(RESOURCES_DIR"images/icon.bmp");
if (icon) {
SDL_WM_SetIcon(icon, NULL);
SDL_FreeSurface(icon);
}
BBEngine app(800, 600, 32);
return app.exec();
}