SplashWindow(): window(nullptr), surface(nullptr), startupScreenRequested(false){ spades::MemoryStream stream(reinterpret_cast<const char*>(splashImage), sizeof(splashImage)); bmp.Set(spades::Bitmap::Load(&stream), false); SDL_InitSubSystem(SDL_INIT_VIDEO|SDL_INIT_TIMER); window = SDL_CreateWindow("OpenSpades Splash Window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, bmp->GetWidth(), bmp->GetHeight(), SDL_WINDOW_BORDERLESS); if(window == nullptr) { SPLog("Creation of splash window failed."); return; } surface = SDL_GetWindowSurface(window); if(surface == nullptr) { SPLog("Creation of splash window surface failed."); SDL_DestroyWindow(window); return; } // put splash image auto *s = SDL_CreateRGBSurfaceFrom(bmp->GetPixels(), bmp->GetWidth(), bmp->GetHeight(), 32, bmp->GetWidth() * 4, 0xff, 0xff00, 0xff0000, 0); SDL_BlitSurface(s, nullptr, surface, nullptr); SDL_FreeSurface(s); SDL_UpdateWindowSurface(window); }
SplashWindow(): window(nullptr), surface(nullptr), startupScreenRequested(false){ spades::MemoryStream stream(reinterpret_cast<const char*>(splashImage), sizeof(splashImage)); bmp.Set(spades::Bitmap::Load(&stream), false); SDL_InitSubSystem(SDL_INIT_VIDEO|SDL_INIT_TIMER); window = SDL_CreateWindow("OpenSpades Splash Window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, bmp->GetWidth(), bmp->GetHeight(), SDL_WINDOW_BORDERLESS); if(window == nullptr) { SPLog("Creation of splash window failed."); return; } surface = SDL_GetWindowSurface(window); if(surface == nullptr) { SPLog("Creation of splash window surface failed."); SDL_DestroyWindow(window); return; } #ifdef __APPLE__ #elif __unix SDL_Surface *icon = nullptr; SDL_RWops *icon_rw = nullptr; icon_rw = SDL_RWFromConstMem(Icon, sizeof(Icon)); if (icon_rw != nullptr) { icon = IMG_LoadPNG_RW(icon_rw); SDL_FreeRW(icon_rw); } if(icon == nullptr) { std::string msg = SDL_GetError(); SPLog("Failed to load icon: %s", msg.c_str()); } else { SDL_SetWindowIcon(window, icon); SDL_FreeSurface(icon); } #endif // put splash image auto *s = SDL_CreateRGBSurfaceFrom(bmp->GetPixels(), bmp->GetWidth(), bmp->GetHeight(), 32, bmp->GetWidth() * 4, 0xff, 0xff00, 0xff0000, 0); SDL_BlitSurface(s, nullptr, surface, nullptr); SDL_FreeSurface(s); SDL_UpdateWindowSurface(window); }