ManaPlus
sdlhelper.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_SDLHELPER_H
23 #define UTILS_SDLHELPER_H
24 
25 #ifdef USE_SDL2
26 #include "utils/sdl2helper.h"
27 UTILS_SDL2HELPER_H
28 
29 #else
30 #include "utils/stringvector.h"
31 
32 #include "localconsts.h"
33 
34 PRAGMA48(GCC diagnostic push)
35 PRAGMA48(GCC diagnostic ignored "-Wshadow")
36 #include <SDL_thread.h>
37 PRAGMA48(GCC diagnostic pop)
38 
39 union SDL_Event;
40 
41 struct SDL_Surface;
42 struct SDL_SysWMinfo;
43 
44 namespace SDL
45 {
46  bool getAllVideoModes(StringVect &modeList);
47 
48  void SetWindowTitle(const SDL_Surface *const window,
49  const char *const title);
50 
51  void SetWindowIcon(const SDL_Surface *const window A_UNUSED,
52  SDL_Surface *const icon);
53 
54  void grabInput(const SDL_Surface *const window A_UNUSED, const bool grab);
55 
56  void setGamma(const SDL_Surface *const window A_UNUSED, const float gamma);
57 
58  void setVsync(const int val);
59 
60  bool getWindowWMInfo(const SDL_Surface *const window A_UNUSED,
61  SDL_SysWMinfo *const info);
62 
63  SDL_Thread *createThread(int (SDLCALL *fn)(void *),
64  const char *const name A_UNUSED,
65  void *const data);
66 
67  void *createGLContext(SDL_Surface *const window A_UNUSED,
68  const int major,
69  const int minor,
70  const int profile);
71 
72  void makeCurrentContext(void *const context);
73 
74  void initLogger();
75 
76  void setLogLevel(const int level);
77 
78  void WaitThread(SDL_Thread *const thread);
79 
80  bool PollEvent(SDL_Event *event);
81 
82  void allowScreenSaver(const bool allow);
83 } // namespace SDL
84 
85 #endif // USE_SDL2
86 #endif // UTILS_SDLHELPER_H
#define PRAGMA48(str)
Definition: localconsts.h:199
#define A_UNUSED
Definition: localconsts.h:160
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
std::vector< std::string > StringVect
Definition: stringvector.h:29