/// <summary> /// Initializes SDL and its components. /// </summary> public static void Start() { Console.WriteLine("Start loading dependencies..."); if (Platform == Platform.Windows) { SetProcessDPIAware(); SDL.Bind("./lib/windows/SDL2.dll", "./lib/windows/zlib1.dll"); if (File.Exists("./lib/windows/libjpeg-9.dll")) { LoadedJPEG = true; SDL_image.Bind("./lib/windows/SDL2_image.dll", "./lib/windows/libpng16-16.dll", "./lib/windows/libjpeg-9.dll"); } else { SDL_image.Bind("./lib/windows/SDL2_image.dll", "./lib/windows/libpng16-16.dll"); } SDL_ttf.Bind("./lib/windows/SDL2_ttf.dll", "./lib/windows/libfreetype-6.dll"); } else if (Platform == Platform.Linux) { SDL.Bind("./lib/linux/SDL2.so", "./lib/linux/libz.so"); if (File.Exists("./lib/linux/libjpeg-9.so")) { LoadedJPEG = true; SDL_image.Bind("./lib/linux/SDL2_image.so", "./lib/linux/libpng16-16.so", "./lib/linux/libjpeg-9.so"); } else { SDL_image.Bind("./lib/linux/SDL2_image.so", "./lib/linux/libpng16-16.so"); } SDL_ttf.Bind("./lib/linux/SDL2_ttf.so", "./lib/linux/libfreetype-6.so"); } else if (Platform == Platform.MacOS) { throw new Exception("MacOS support has not yet been implemented."); } else { throw new Exception("No platform could be detected."); } uint IMG_Flags = IMG_INIT_PNG; if (LoadedJPEG) { IMG_Flags |= IMG_INIT_JPG; } if (SDL_Init(SDL_INIT_EVERYTHING) < 0 || IMG_Init(IMG_Flags) != (int)IMG_Flags || TTF_Init() < 0) { throw new Exception(SDL_GetError()); } int screens = SDL_GetNumVideoDisplays(); for (int i = 0; i < screens; i++) { SDL_Rect r; if (SDL_GetDisplayBounds(i, out r) != 0) { throw new Exception($"Could not retrieve screen size for screen {i}: {SDL_GetError()}"); } Screens.Add(new Rect(r)); } SDL_StopTextInput(); Initialized = true; }