2017-10-05 17:22:14 +02:00
|
|
|
#include "dump1090.h"
|
2017-09-14 05:21:36 +02:00
|
|
|
#include "init.h"
|
2017-10-05 17:22:14 +02:00
|
|
|
|
2019-09-08 01:11:20 +02:00
|
|
|
void init(char *title) {
|
2017-10-05 17:22:14 +02:00
|
|
|
// raspberry pi compiler flag enables these options
|
|
|
|
#ifdef RPI
|
2017-09-16 04:25:26 +02:00
|
|
|
putenv((char*)"FRAMEBUFFER=/dev/fb1");
|
|
|
|
putenv((char*)"SDL_FBDEV=/dev/fb1");
|
|
|
|
#endif
|
2017-09-05 11:41:46 +02:00
|
|
|
|
2019-09-08 01:11:20 +02:00
|
|
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
|
|
|
printf("Could not initialize SDL: %s\n", SDL_GetError());
|
2017-09-14 05:21:36 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-08 01:11:20 +02:00
|
|
|
if (TTF_Init() < 0) {
|
2017-09-14 05:21:36 +02:00
|
|
|
printf("Couldn't initialize SDL TTF: %s\n", SDL_GetError());
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2019-09-08 01:11:20 +02:00
|
|
|
// #ifdef RPI
|
|
|
|
// const SDL_VideoInfo* vInfo = SDL_GetVideoInfo();
|
2017-10-05 17:22:14 +02:00
|
|
|
|
2019-09-08 01:11:20 +02:00
|
|
|
// if (!vInfo) {
|
|
|
|
// fprintf(stderr,"ERROR in SDL_GetVideoInfo(): %s\n",SDL_GetError());
|
|
|
|
// exit(1);
|
|
|
|
// }
|
2017-10-05 16:58:23 +02:00
|
|
|
|
2019-09-08 01:11:20 +02:00
|
|
|
// Modes.screen_width = vInfo->current_w;
|
|
|
|
// Modes.screen_height = vInfo->current_h;
|
|
|
|
// Modes.screen_depth = vInfo->vfmt->BitsPerPixel;
|
2017-10-06 05:32:36 +02:00
|
|
|
|
2019-09-08 01:11:20 +02:00
|
|
|
// Modes.screen_upscale = 1;
|
|
|
|
// #endifX
|
|
|
|
SDL_ShowCursor(SDL_DISABLE);
|
2017-10-05 16:58:23 +02:00
|
|
|
|
2019-09-08 01:11:20 +02:00
|
|
|
Uint32 flags = 0;
|
2018-10-01 08:44:17 +02:00
|
|
|
|
|
|
|
if(Modes.fullscreen) {
|
2019-09-08 01:11:20 +02:00
|
|
|
flags = flags | SDL_WINDOW_FULLSCREEN_DESKTOP;
|
2018-10-01 08:44:17 +02:00
|
|
|
}
|
2017-10-05 16:58:23 +02:00
|
|
|
|
2019-09-08 01:11:20 +02:00
|
|
|
game.window = SDL_CreateWindow(title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, Modes.screen_width, Modes.screen_height, flags);
|
|
|
|
game.renderer = SDL_CreateRenderer(game.window, -1, 0);
|
|
|
|
game.texture = SDL_CreateTexture(game.renderer,
|
|
|
|
SDL_PIXELFORMAT_ARGB8888,
|
|
|
|
SDL_TEXTUREACCESS_STREAMING,
|
|
|
|
Modes.screen_width, Modes.screen_height);
|
2017-10-06 05:25:30 +02:00
|
|
|
|
2019-09-08 01:11:20 +02:00
|
|
|
if(Modes.fullscreen) {
|
|
|
|
//SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); // make the scaled rendering look smoother.
|
|
|
|
SDL_RenderSetLogicalSize(game.renderer, Modes.screen_width, Modes.screen_height);
|
2017-09-14 05:21:36 +02:00
|
|
|
}
|
2017-09-16 04:25:26 +02:00
|
|
|
|
2018-10-01 08:44:17 +02:00
|
|
|
game.mapFont = loadFont("font/TerminusTTF-4.46.0.ttf", 12 * Modes.screen_uiscale);
|
|
|
|
game.mapBoldFont = loadFont("font/TerminusTTF-Bold-4.46.0.ttf", 12 * Modes.screen_uiscale);
|
2017-09-17 17:38:22 +02:00
|
|
|
|
2019-09-08 21:29:21 +02:00
|
|
|
game.listFont = loadFont("font/TerminusTTF-4.46.0.ttf", 12 * Modes.screen_uiscale);
|
2017-10-06 05:25:30 +02:00
|
|
|
|
2019-09-08 01:11:20 +02:00
|
|
|
game.messageFont = loadFont("font/TerminusTTF-Bold-4.46.0.ttf", 12 * Modes.screen_uiscale);
|
|
|
|
game.labelFont = loadFont("font/TerminusTTF-Bold-4.46.0.ttf", 12 * Modes.screen_uiscale);
|
2017-10-06 18:34:36 +02:00
|
|
|
|
2018-10-01 08:44:17 +02:00
|
|
|
game.mapFontWidth = 5 * Modes.screen_uiscale;
|
|
|
|
game.mapFontHeight = 12 * Modes.screen_uiscale;
|
2017-10-06 18:34:36 +02:00
|
|
|
|
2019-09-08 01:11:20 +02:00
|
|
|
game.messageFontWidth = 6 * Modes.screen_uiscale;
|
|
|
|
game.messageFontHeight = 12 * Modes.screen_uiscale;
|
2017-10-06 18:34:36 +02:00
|
|
|
|
2019-09-08 01:11:20 +02:00
|
|
|
game.labelFontWidth = 6 * Modes.screen_uiscale;
|
|
|
|
game.labelFontHeight = 12 * Modes.screen_uiscale;
|
2017-09-17 16:46:48 +02:00
|
|
|
|
|
|
|
initMaps();
|
2019-09-08 01:11:20 +02:00
|
|
|
|
2017-09-14 05:21:36 +02:00
|
|
|
}
|
|
|
|
|
2019-09-08 01:11:20 +02:00
|
|
|
void cleanup() {
|
2017-10-10 22:56:05 +02:00
|
|
|
closeFont(game.mapFont);
|
|
|
|
closeFont(game.mapBoldFont);
|
|
|
|
closeFont(game.messageFont);
|
|
|
|
closeFont(game.labelFont);
|
|
|
|
closeFont(game.listFont);
|
|
|
|
|
2017-09-14 05:21:36 +02:00
|
|
|
TTF_Quit();
|
2017-09-17 19:58:42 +02:00
|
|
|
|
2017-09-14 05:21:36 +02:00
|
|
|
SDL_Quit();
|
|
|
|
}
|