viz1090/init.c
nathan 081ecda409 moving everything out of dump1090.h and interactive.c
Former-commit-id: 09fc0bec299442fa1ac44ee6e41f237134ab2b73
Former-commit-id: 0f3edc36d54876849854abd4ef5ab8531f374b38
2019-09-08 23:23:38 -05:00

74 lines
2.3 KiB
C

#include "dump1090.h"
#include "structs.h"
void init(char *title) {
// raspberry pi compiler flag enables these options
#ifdef RPI
putenv((char*)"FRAMEBUFFER=/dev/fb1");
putenv((char*)"SDL_FBDEV=/dev/fb1");
#endif
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
printf("Could not initialize SDL: %s\n", SDL_GetError());
exit(1);
}
if (TTF_Init() < 0) {
printf("Couldn't initialize SDL TTF: %s\n", SDL_GetError());
exit(1);
}
SDL_ShowCursor(SDL_DISABLE);
Uint32 flags = 0;
if(appData.fullscreen) {
flags = flags | SDL_WINDOW_FULLSCREEN_DESKTOP;
}
appData.window = SDL_CreateWindow(title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, appData.screen_width, appData.screen_height, flags);
appData.renderer = SDL_CreateRenderer(appData.window, -1, 0);
appData.texture = SDL_CreateTexture(appData.renderer,
SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING,
appData.screen_width, appData.screen_height);
if(appData.fullscreen) {
//SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); // make the scaled rendering look smoother.
SDL_RenderSetLogicalSize(appData.renderer, appData.screen_width, appData.screen_height);
}
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);
appData.listFont = loadFont("font/TerminusTTF-4.46.0.ttf", 12 * appData.screen_uiscale);
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);
appData.mapFontWidth = 5 * appData.screen_uiscale;
appData.mapFontHeight = 12 * appData.screen_uiscale;
appData.messageFontWidth = 6 * appData.screen_uiscale;
appData.messageFontHeight = 12 * appData.screen_uiscale;
appData.labelFontWidth = 6 * appData.screen_uiscale;
appData.labelFontHeight = 12 * appData.screen_uiscale;
initMaps();
}
void cleanup() {
closeFont(appData.mapFont);
closeFont(appData.mapBoldFont);
closeFont(appData.messageFont);
closeFont(appData.labelFont);
closeFont(appData.listFont);
TTF_Quit();
SDL_Quit();
}