static void scan_env() { static bool first = true; if (! first) return; first = false; printf("libGL: built on %s %s\n", __DATE__, __TIME__); #define env(name, global, message) \ char *env_##name = getenv(#name); \ if (env_##name && strcmp(env_##name, "1") == 0) { \ printf("libGL: " message "\n"); \ global = true; \ } env(LIBGL_XREFRESH, g_xrefresh, "xrefresh will be called on cleanup"); env(LIBGL_STACKTRACE, g_stacktrace, "stacktrace will be printed on crash"); if (g_xrefresh || g_stacktrace || g_bcmhost) { // TODO: a bit gross. Maybe look at this: http://stackoverflow.com/a/13290134/293352 signal(SIGBUS, signal_handler); signal(SIGFPE, signal_handler); signal(SIGILL, signal_handler); signal(SIGSEGV, signal_handler); if (g_xrefresh || g_bcmhost) { signal(SIGINT, signal_handler); signal(SIGQUIT, signal_handler); signal(SIGTERM, signal_handler); } if (g_xrefresh) atexit(xrefresh); #ifdef BCMHOST atexit(bcm_host_deinit); #endif } env(LIBGL_FB, g_usefb, "framebuffer output enabled"); env(LIBGL_FPS, g_showfps, "fps counter enabled"); env(LIBGL_VSYNC, g_vsync, "vsync enabled"); if (g_vsync) { init_vsync(); } }
int32_t gui_init (void) { SDL_JoystickEventState(SDL_ENABLE); SDL_JoystickOpen(0); SDL_ShowCursor(SDL_DISABLE); TTF_Init(); amiga_font = TTF_OpenFont(FONT_DIR "/amiga4ever_pro2.ttf", 16); if (!amiga_font) { printf("SDLUI: TTF_OpenFont failed: %s\n", TTF_GetError()); abort(); } text_color.r = 50; text_color.g = 50; text_color.b = 50; if(!pMainMenu_Surface) pMainMenu_Surface = SDL_LoadBMP(IMAGE_DIR "/menu.bmp"); menu_load_surface(pMainMenu_Surface); if (pMenu_Surface == NULL) { write_log ("SDLUI: Failed to load menu image\n"); abort(); } pMouse_Pointer = SDL_LoadBMP(IMAGE_DIR "/mousep_33x33_wb20.bmp"); if (pMouse_Pointer == NULL) { write_log ("SDLUI: Failed to load mouse pointer image\n"); abort(); } SDL_SetColorKey(pMouse_Pointer, SDL_SRCCOLORKEY, SDL_MapRGB(pMouse_Pointer->format, 68, 94, 174)); icon_expansion = SDL_LoadBMP(IMAGE_DIR "/icon-expansion.bmp"); if (icon_expansion == NULL) { write_log ("SDLUI: Failed to load icon expansion\n"); abort(); } icon_preferences = SDL_LoadBMP(IMAGE_DIR "/icon-preferences.bmp"); if (icon_preferences == NULL) { write_log ("SDLUI: Failed to load icon preferences\n"); abort(); } icon_keymaps = SDL_LoadBMP(IMAGE_DIR "/icon-keymaps.bmp"); if (icon_keymaps == NULL) { write_log ("SDLUI: Failed to load icon keymaps\n"); abort(); } icon_floppy = SDL_LoadBMP(IMAGE_DIR "/icon-floppy.bmp"); if (icon_floppy == NULL) { write_log ("SDLUI: Failed to load icon floppy\n"); abort(); } icon_reset = SDL_LoadBMP(IMAGE_DIR "/icon-reset.bmp"); if (icon_reset == NULL) { write_log ("SDLUI: Failed to load icon reset\n"); abort(); } icon_storage = SDL_LoadBMP(IMAGE_DIR "/icon-storage.bmp"); if (icon_storage == NULL) { write_log ("SDLUI: Failed to load icon storage\n"); abort(); } icon_run = SDL_LoadBMP(IMAGE_DIR "/icon-run.bmp"); if (icon_run == NULL) { write_log ("SDLUI: Failed to load icon run\n"); abort(); } icon_exit = SDL_LoadBMP(IMAGE_DIR "/icon-exit.bmp"); if (icon_exit == NULL) { write_log ("SDLUI: Failed to load icon exit\n"); abort(); } icon_tweaks = SDL_LoadBMP(IMAGE_DIR "/icon-tweaks.bmp"); if (icon_tweaks == NULL) { write_log ("SDLUI: Failed to load icon tweaks\n"); abort(); } init_vsync(); gui_initialized = true; return 1; }