2017-10-05 17:22:14 +02:00
|
|
|
#include "dump1090.h"
|
2019-09-09 06:23:38 +02:00
|
|
|
#include "structs.h"
|
2020-03-07 05:51:47 +01:00
|
|
|
#include "monokai.h"
|
2017-10-05 17:22:14 +02:00
|
|
|
|
2019-09-08 01:11:20 +02:00
|
|
|
void init(char *title) {
|
2020-01-20 07:22:58 +01:00
|
|
|
|
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
|
|
|
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
|
|
|
|
2019-09-09 06:23:38 +02:00
|
|
|
if(appData.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-22 03:46:52 +02:00
|
|
|
if(appData.screen_width == 0) {
|
|
|
|
SDL_DisplayMode DM;
|
|
|
|
SDL_GetCurrentDisplayMode(0, &DM);
|
|
|
|
appData.screen_width = DM.w;
|
|
|
|
appData.screen_height= DM.h;
|
|
|
|
}
|
|
|
|
|
2020-03-12 20:45:27 +01:00
|
|
|
appData.window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED_DISPLAY(appData.screen_index), SDL_WINDOWPOS_CENTERED_DISPLAY(appData.screen_index), appData.screen_width, appData.screen_height, flags);
|
2020-03-03 07:22:35 +01:00
|
|
|
appData.renderer = SDL_CreateRenderer(appData.window, -1, SDL_RENDERER_ACCELERATED);
|
2020-02-18 07:19:45 +01:00
|
|
|
appData.mapTexture = SDL_CreateTexture(appData.renderer,
|
2019-09-08 01:11:20 +02:00
|
|
|
SDL_PIXELFORMAT_ARGB8888,
|
2020-02-18 07:19:45 +01:00
|
|
|
SDL_TEXTUREACCESS_TARGET,
|
2019-09-09 06:23:38 +02:00
|
|
|
appData.screen_width, appData.screen_height);
|
2017-10-06 05:25:30 +02:00
|
|
|
|
2020-02-18 07:19:45 +01:00
|
|
|
appData.mapMoved = 1;
|
2020-03-07 00:44:45 +01:00
|
|
|
appData.mapTargetLon = 0;
|
|
|
|
appData.mapTargetLat = 0;
|
|
|
|
appData.mapTargetMaxDist = 0;
|
2020-03-07 05:51:47 +01:00
|
|
|
appData.isDragging = 0;
|
2020-02-18 07:19:45 +01:00
|
|
|
|
2019-09-09 06:23:38 +02:00
|
|
|
if(appData.fullscreen) {
|
2020-03-03 08:07:39 +01:00
|
|
|
//SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); // make the scaled rendering look smoother.
|
2019-09-09 06:23:38 +02:00
|
|
|
SDL_RenderSetLogicalSize(appData.renderer, appData.screen_width, appData.screen_height);
|
2017-09-14 05:21:36 +02:00
|
|
|
}
|
2017-09-16 04:25:26 +02:00
|
|
|
|
2019-09-09 06:23:38 +02:00
|
|
|
appData.mapFont = loadFont("font/TerminusTTF-4.46.0.ttf", 12 * appData.screen_uiscale);
|
|
|
|
appData.mapBoldFont = loadFont("font/TerminusTTF-Bold-4.46.0.ttf", 12 * appData.screen_uiscale);
|
2017-09-17 17:38:22 +02:00
|
|
|
|
2019-09-09 06:23:38 +02:00
|
|
|
appData.listFont = loadFont("font/TerminusTTF-4.46.0.ttf", 12 * appData.screen_uiscale);
|
2017-10-06 05:25:30 +02:00
|
|
|
|
2019-09-09 06:23:38 +02:00
|
|
|
appData.messageFont = loadFont("font/TerminusTTF-Bold-4.46.0.ttf", 12 * appData.screen_uiscale);
|
|
|
|
appData.labelFont = loadFont("font/TerminusTTF-Bold-4.46.0.ttf", 12 * appData.screen_uiscale);
|
2017-10-06 18:34:36 +02:00
|
|
|
|
2019-09-09 06:23:38 +02:00
|
|
|
appData.mapFontWidth = 5 * appData.screen_uiscale;
|
|
|
|
appData.mapFontHeight = 12 * appData.screen_uiscale;
|
2017-10-06 18:34:36 +02:00
|
|
|
|
2019-09-09 06:23:38 +02:00
|
|
|
appData.messageFontWidth = 6 * appData.screen_uiscale;
|
|
|
|
appData.messageFontHeight = 12 * appData.screen_uiscale;
|
2017-10-06 18:34:36 +02:00
|
|
|
|
2019-09-09 06:23:38 +02:00
|
|
|
appData.labelFontWidth = 6 * appData.screen_uiscale;
|
|
|
|
appData.labelFontHeight = 12 * appData.screen_uiscale;
|
2017-09-17 16:46:48 +02:00
|
|
|
|
2020-03-07 05:51:47 +01:00
|
|
|
SDL_Color bgcolor = {10,20,30,255};
|
|
|
|
SDL_Color greenblue = {236,192,68,255};
|
|
|
|
SDL_Color lightblue = {211,208,203,255};
|
|
|
|
SDL_Color mediumblue ={110,136,152,255};
|
|
|
|
SDL_Color darkblue = {46,82,102,255};
|
|
|
|
|
|
|
|
style.backgroundColor = bgcolor;
|
|
|
|
style.selectedColor = pink;
|
|
|
|
style.planeColor = greenblue;
|
|
|
|
style.planeGoneColor = grey;
|
|
|
|
style.mapInnerColor = mediumblue;
|
|
|
|
style.mapOuterColor = darkblue;
|
|
|
|
style.scaleBarColor = lightGrey;
|
|
|
|
style.buttonColor = lightblue;
|
|
|
|
|
2017-09-17 16:46:48 +02:00
|
|
|
initMaps();
|
2017-09-14 05:21:36 +02:00
|
|
|
}
|
|
|
|
|
2019-09-08 01:11:20 +02:00
|
|
|
void cleanup() {
|
2019-09-09 06:23:38 +02:00
|
|
|
closeFont(appData.mapFont);
|
|
|
|
closeFont(appData.mapBoldFont);
|
|
|
|
closeFont(appData.messageFont);
|
|
|
|
closeFont(appData.labelFont);
|
|
|
|
closeFont(appData.listFont);
|
2017-10-10 22:56:05 +02:00
|
|
|
|
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();
|
|
|
|
}
|