-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·52 lines (44 loc) · 1.09 KB
/
main.cpp
File metadata and controls
executable file
·52 lines (44 loc) · 1.09 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
#include <filesystem>
#include <iostream>
#include <string>
#include <locale>
#include <SDL.h>
#include "control.h"
#include "text.h"
#include "util.h"
using namespace std;
namespace fs = std::filesystem;
int main(int argc, char **argv)
{
// Enable UTF-8 multibyte encoding
setlocale(LC_ALL, "en_US.UTF-8");
// Print usage
if (argc != 2) {
cerr << "Usage: " << argv[0] << " <path>" << endl;
return 1;
}
// Set respath
Util::_respath = fs::path(argv[0]).parent_path() / "res";
// Load font
Text::_font.reset(
[]() -> TTF_Font* {
// Initialize SDL_ttf subsystem
if (TTF_Init() < 0) {
cerr << "Failed to initialise SDL_ttf: " << TTF_GetError() << endl;
exit(1);
}
// Load the default font
fs::path p = Util::get_respath("estre.ttf");
TTF_Font* f = TTF_OpenFont(p.string().c_str(), 15);
if (!f) {
cerr << "Failed to load font: " << TTF_GetError() << endl;
exit(1);
}
return f;
}()
);
// Initialize controller & loop
Control::init(argv[1]);
Control::loop();
return 0;
}