GLVis  v4.2
Accurate and flexible finite element visualization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
sdl_helper.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2022, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-443271.
4 //
5 // This file is part of the GLVis visualization tool and library. For more
6 // information and source code availability see https://glvis.org.
7 //
8 // GLVis is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
11 
12 #include <iostream>
13 
14 #include "sdl_helper.hpp"
15 
16 #ifndef __EMSCRIPTEN__
17 #include <SDL2/SDL_syswm.h>
18 #else
19 #include <SDL_syswm.h>
20 #endif
21 
22 #include "sdl_x11.hpp"
23 #include "sdl_mac.hpp"
24 #include "sdl_windows.hpp"
25 
26 using namespace std;
27 
28 std::unique_ptr<SdlNativePlatform>
29 SdlNativePlatform::Create(SDL_Window* window)
30 {
31  SDL_SysWMinfo sysinfo;
32  SDL_VERSION(&sysinfo.version);
33  if (!SDL_GetWindowWMInfo(window, &sysinfo))
34  {
35  cerr << "Error: unable to get window manager information for the "
36  << "current window." << endl;
37  return {};
38  }
39  switch (sysinfo.subsystem)
40  {
41 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
42  case SDL_SYSWM_WINDOWS:
43  return std::unique_ptr<SdlNativePlatform> {new SdlWindowsPlatform};
44 #endif
45 #if defined(SDL_VIDEO_DRIVER_COCOA)
46  case SDL_SYSWM_COCOA:
47  return std::unique_ptr<SdlNativePlatform> {new SdlCocoaPlatform};
48 #endif
49 #if defined(SDL_VIDEO_DRIVER_X11)
50  case SDL_SYSWM_X11:
51  return std::unique_ptr<SdlNativePlatform> {new SdlX11Platform};
52 #endif
53  case SDL_SYSWM_UNKNOWN:
54  default:
55  cerr << "Error: unrecognized window manager system." << endl;
56  return {};
57  }
58 }
static std::unique_ptr< SdlNativePlatform > Create(SDL_Window *window)
Definition: sdl_helper.cpp:29