SHARE
TWEET

main.cpp

a guest Jan 7th, 2020 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <SDL.h>
  3.  
  4. int main()
  5. {
  6. //  uint32_t windowStyleSDL = SDL_WINDOW_VULKAN;
  7.     SDL_SetHint("SDL_VIDEO_X11_REQUIRE_XRANDR", "1");  // workaround for misbuilt SDL libraries on X11.
  8.    
  9. //  SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_SHOW_CURSOR, "1"); // When relative mouse mode is acive, don't hide cursor.
  10.     SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "0"); // Don't warp the cursor to the center in relative mouse mode.
  11.    
  12.     if (SDL_Init((SDL_INIT_EVERYTHING ^ SDL_INIT_AUDIO) | SDL_INIT_NOPARACHUTE) != 0)
  13.         std::cout << "SDL could not be inited.\n";
  14.    
  15.     SDL_version CompileTimeSDLVersion;
  16.     SDL_version RunTimeSDLVersion;
  17.     SDL_VERSION(&CompileTimeSDLVersion);
  18.     SDL_GetVersion(&RunTimeSDLVersion);
  19.     int SdlRevisionNum = SDL_GetRevisionNumber();
  20.     const char *SdlRevision = SDL_GetRevision();
  21.     std::cout <<  "Init SDL version: " << (unsigned int)RunTimeSDLVersion.major << "."
  22.         << (unsigned int)RunTimeSDLVersion.minor << "." << (unsigned int)RunTimeSDLVersion.patch
  23.         << " revision: " << SdlRevisionNum << " (" << SdlRevision << ") (compiled against: " << (unsigned int)CompileTimeSDLVersion.major
  24.         << "." << (unsigned int)CompileTimeSDLVersion.minor << "."
  25.         << (unsigned int)CompileTimeSDLVersion.patch << ")\n";
  26.    
  27.     const char *SdlVideoDriver = SDL_GetCurrentVideoDriver();
  28.     if (SdlVideoDriver)
  29.         std::cout << "Using SDL video driver: " << SdlVideoDriver << "\n";
  30.    
  31.     SDL_StartTextInput();
  32.    
  33.     const char *title = "Title";
  34.     const char *message = "message";
  35.     SDL_MessageBoxButtonData *buttons = new SDL_MessageBoxButtonData[2];
  36.     buttons[0].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
  37.     buttons[0].text = "Yes";
  38.     buttons[0].buttonid = 1;
  39.     buttons[1].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
  40.     buttons[1].text = "No";
  41.     buttons[1].buttonid = 0;
  42.    
  43.     SDL_MessageBoxData messageBoxData =
  44.     {
  45.             SDL_MESSAGEBOX_INFORMATION,
  46.             NULL,
  47.             title,
  48.             message,
  49.             2,
  50.             buttons,
  51.             NULL
  52.     };
  53.    
  54.     int buttonPressed = -1;
  55.     if (SDL_ShowMessageBox(&messageBoxData, &buttonPressed) == -1)
  56.         std::cout << "Messagebox could not be shown\n";
  57.    
  58.     return 0;
  59. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top