MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / SDL_AppInit

Function SDL_AppInit

src/main.cpp:450–586  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

448}
449
450SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) {
451 std::vector<std::filesystem::path> listOfFilesToOpenFromCommand;
452 for(int i = 1; i < argc; i++)
453 listOfFilesToOpenFromCommand.emplace_back(std::filesystem::canonical(std::filesystem::path(std::u8string_view(reinterpret_cast<char8_t*>(argv[i])))));
454 switch_cwd();
455
456 UErrorCode uerr = U_ZERO_ERROR;
457 icudt = read_file_to_string("data/icudt77l-small.dat");
458 udata_setCommonData((void *) icudt.data(), &uerr);
459 if (U_FAILURE(uerr)) {
460 char* errorName = const_cast<char*>(u_errorName(uerr));
461 std::cout << "Failed to load icudt77l-small.dat" << std::endl;
462 std::cout << errorName << std::endl;
463 }
464
465 MainStruct* mSPtr = new MainStruct;
466 *appstate = (void*)mSPtr;
467 MainStruct& mS = *mSPtr;
468
469 init_logs(mS);
470
471 FileDownloader::init();
472
473#ifdef NDEBUG
474 try {
475#endif
476 mS.m = std::make_unique<MainProgram>();
477 mS.m->logFile = &mS.logFile;
478 mS.m->conf.configPath = mS.configPath;
479 mS.m->homePath = mS.homePath;
480 #ifndef __EMSCRIPTEN__
481 const char* documentsPathSDL = SDL_GetUserFolder(SDL_FOLDER_DOCUMENTS);
482 if(!documentsPathSDL) {
483 documentsPathSDL = SDL_GetUserFolder(SDL_FOLDER_DESKTOP);
484 if(!documentsPathSDL)
485 mS.m->documentsPath = mS.m->conf.configPath;
486 else
487 mS.m->documentsPath = std::filesystem::path(documentsPathSDL);
488 }
489 else
490 mS.m->documentsPath = std::filesystem::path(documentsPathSDL);
491 #endif
492 mS.m->update_scale_and_density();
493 mS.m->load_config();
494
495 initialize_sdl(mS);
496
497 CustomEvents::init();
498
499 int32_t cursorData[2] = {0, 0};
500 mS.hiddenCursor = SDL_CreateCursor((Uint8 *)cursorData, (Uint8 *)cursorData, 8, 8, 4, 4);
501 #ifdef __EMSCRIPTEN__
502 emscripten_set_beforeunload_callback((void*)mSPtr, emscripten_before_unload);
503 #endif
504 #ifdef USE_BACKEND_VULKAN
505 #ifdef USE_SKIA_BACKEND_GRAPHITE
506 std::unique_ptr<const skwindow::DisplayParams> displayParams = skwindow::DisplayParamsBuilder().build();
507

Callers

nothing calls this directly

Calls 15

canonicalClass · 0.85
switch_cwdFunction · 0.85
read_file_to_stringFunction · 0.85
init_logsFunction · 0.85
initFunction · 0.85
initialize_sdlFunction · 0.85
resize_windowFunction · 0.85
load_configMethod · 0.80
graphiteRecorderMethod · 0.80
set_first_screenMethod · 0.80
create_new_tabMethod · 0.80

Tested by

no test coverage detected