MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / run

Method run

Source/Basic/Application.cpp:804–991  ·  view source on GitHub ↗

This function runs in main (render) thread, and do render work

Source from the content-addressed store, hash-verified

802
803// This function runs in main (render) thread, and do render work
804int Application::run(MainFunc mainFunc) {
805 _mainFunc = mainFunc;
806 Application::setSeed(s_cast<uint32_t>(std::time(nullptr)));
807
808 if (SDL_Init(SDL_INIT_GAMECONTROLLER) != 0) {
809 Error("SDL failed to initialize! {}", SDL_GetError());
810 return 1;
811 }
812
813 SharedController.initInRender();
814
815 SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "1");
816 SDL_SetHint(SDL_HINT_VIDEO_EXTERNAL_CONTEXT, "1");
817 SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");
818 SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight");
819
820 uint32_t windowFlags = SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_RESIZABLE;
821#if BX_PLATFORM_WINDOWS || BX_PLATFORM_OSX || BX_PLATFORM_LINUX
822 windowFlags |= SDL_WINDOW_HIDDEN;
823#if BX_PLATFORM_LINUX
824 const char* videoDriver = SDL_GetCurrentVideoDriver();
825 const bool useKmsdrmGL = videoDriver && std::strcmp(videoDriver, "KMSDRM") == 0;
826 if (useKmsdrmGL) {
827 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
828 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
829 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
830 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
831 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
832 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
833 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
834 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
835 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
836 windowFlags |= SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS;
837 _fullScreen = true;
838 }
839#endif // BX_PLATFORM_LINUX
840 if (_alwaysOnTop) {
841 windowFlags |= SDL_WINDOW_ALWAYS_ON_TOP;
842 }
843#elif BX_PLATFORM_IOS || BX_PLATFORM_ANDROID
844 windowFlags |= SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS;
845 _fullScreen = true;
846#endif // BX_PLATFORM
847
848 _sdlWindow = SDL_CreateWindow("Dora SSR",
849 SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
850 _winWidth, _winHeight, windowFlags);
851 if (!_sdlWindow) {
852 Error("SDL failed to create window! {}", SDL_GetError());
853 return 1;
854 }
855
856#if BX_PLATFORM_WINDOWS || BX_PLATFORM_OSX || BX_PLATFORM_LINUX
857 int displayIndex = SDL_GetWindowDisplayIndex(_sdlWindow);
858 SDL_Rect rect;
859 if (SDL_GetDisplayBounds(displayIndex, &rect) == 0 && (_winWidth > rect.w || _winHeight > rect.h)) {
860 _winWidth = rect.w;
861 _winHeight = rect.h;

Callers

nothing calls this directly

Calls 15

timeFunction · 0.85
SDL_InitFunction · 0.85
SDL_GetErrorFunction · 0.85
SDL_SetHintFunction · 0.85
strcmpFunction · 0.85
SDL_GL_SetAttributeFunction · 0.85
SDL_CreateWindowFunction · 0.85
SDL_GetDisplayBoundsFunction · 0.85
SDL_SetWindowSizeFunction · 0.85
renderFrameFunction · 0.85

Tested by

no test coverage detected