ManaPlus
sdl2helper.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2013-2019 The ManaPlus Developers
4  * Copyright (C) 2019-2021 Andrei Karas
5  *
6  * This file is part of The ManaPlus Client.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef UTILS_SDL2HELPER_H
23 #define UTILS_SDL2HELPER_H
24 
25 #ifdef USE_SDL2
26 #include "utils/stringvector.h"
27 
28 #include "localconsts.h"
29 
30 PRAGMA48(GCC diagnostic push)
31 PRAGMA48(GCC diagnostic ignored "-Wshadow")
32 #include <SDL_thread.h>
33 PRAGMA48(GCC diagnostic pop)
34 
35 union SDL_Event;
36 
37 struct SDL_Surface;
38 struct SDL_SysWMinfo;
39 struct SDL_Window;
40 
41 namespace SDL
42 {
43  bool getAllVideoModes(StringVect &modeList);
44 
45  void SetWindowTitle(SDL_Window *const window, const char *const title);
46 
47  void SetWindowIcon(SDL_Window *const window, SDL_Surface *const icon);
48 
49  void grabInput(SDL_Window *const window, const bool grab);
50 
51  void setGamma(SDL_Window *const window, const float gamma);
52 
53  void setVsync(const int val);
54 
55  bool getWindowWMInfo(SDL_Window *const window, SDL_SysWMinfo *const info);
56 
57  SDL_Thread *createThread(SDL_ThreadFunction fn,
58  const char *restrict const name,
59  void *restrict const data);
60 
61  void *createGLContext(SDL_Window *const window,
62  const int major,
63  const int minor,
64  const int profile);
65 
66  void makeCurrentContext(void *const context);
67 
68  void initLogger();
69 
70  void setLogLevel(const int level);
71 
72  void WaitThread(SDL_Thread *const thread);
73 
74  bool PollEvent(SDL_Event *event);
75 
76  void allowScreenSaver(const bool allow);
77 
78  void getRenderers(StringVect &list,
79  const std::string &currentRenderer);
80 
81  void setRendererHint(const std::string &driver);
82 } // namespace SDL
83 
84 #endif // USE_SDL2
85 #endif // UTILS_SDL2HELPER_H
#define restrict
Definition: localconsts.h:165
#define PRAGMA48(str)
Definition: localconsts.h:199
uint32_t data
bool info(InputEvent &event)
Definition: commands.cpp:57
Definition: sdlhelper.h:45
SDL_Thread * createThread(int(*fn)(void *), const char *const name, void *const data)
Definition: sdlhelper.cpp:118
void SetWindowTitle(const SDL_Surface *const window, const char *const title)
Definition: sdlhelper.cpp:85
void initLogger()
Definition: sdlhelper.cpp:187
void WaitThread(SDL_Thread *const thread)
Definition: sdlhelper.cpp:195
bool PollEvent(SDL_Event *event)
Definition: sdlhelper.cpp:201
bool getWindowWMInfo(const SDL_Surface *const window, SDL_SysWMinfo *const info)
Definition: sdlhelper.cpp:112
void setLogLevel(const int level)
Definition: sdlhelper.cpp:191
void SetWindowIcon(const SDL_Surface *const window, SDL_Surface *const icon)
Definition: sdlhelper.cpp:91
void makeCurrentContext(void *const context)
Definition: sdlhelper.cpp:182
void grabInput(const SDL_Surface *const window, const bool grab)
Definition: sdlhelper.cpp:97
void setGamma(const SDL_Surface *const window, const float gamma)
Definition: sdlhelper.cpp:102
void setVsync(const int val)
Definition: sdlhelper.cpp:107
bool getAllVideoModes(StringVect &modeList)
Definition: sdlhelper.cpp:44
void allowScreenSaver(const bool allow)
Definition: sdlhelper.cpp:210
void * createGLContext(SDL_Surface *const window, const int major, const int minor, const int profile)
Definition: sdlhelper.cpp:174
#define SDL_Window
Definition: sdlshared.h:60
std::vector< std::string > StringVect
Definition: stringvector.h:29