ManaPlus
Functions
SDL Namespace Reference

Functions

bool getAllVideoModes (StringVect &modeList)
 
void SetWindowTitle (const SDL_Surface *const window, const char *const title)
 
void SetWindowIcon (const SDL_Surface *const window, SDL_Surface *const icon)
 
void grabInput (const SDL_Surface *const window, const bool grab)
 
void setGamma (const SDL_Surface *const window, const float gamma)
 
void setVsync (const int val)
 
bool getWindowWMInfo (const SDL_Surface *const window, SDL_SysWMinfo *const info)
 
SDL_Thread * createThread (int(*fn)(void *), const char *const name, void *const data)
 
void * createGLContext (SDL_Surface *const window, const int major, const int minor, const int profile)
 
void makeCurrentContext (void *const context)
 
void initLogger ()
 
void setLogLevel (const int level)
 
void WaitThread (SDL_Thread *const thread)
 
bool PollEvent (SDL_Event *event)
 
void allowScreenSaver (const bool allow)
 
int MixOpenAudio (const int frequency, const uint16_t format, const int nchannels, const int chunksize)
 
Mix_Music * LoadMUSOgg_RW (SDL_RWops *const rw)
 
void showCursor (const bool show)
 

Function Documentation

◆ allowScreenSaver()

void SDL::allowScreenSaver ( const bool  allow)

Definition at line 210 of file sdlhelper.cpp.

211 {
212  if (allow)
213  setEnv("SDL_VIDEO_ALLOW_SCREENSAVER", "1");
214  else
215  setEnv("SDL_VIDEO_ALLOW_SCREENSAVER", "0");
216 }
void setEnv(const char *const name, const char *const value)
Definition: env.cpp:60

References setEnv().

Referenced by Client::gameInit().

◆ createGLContext()

void * SDL::createGLContext ( SDL_Surface *const  window,
const int  major,
const int  minor,
const int  profile 
)

Definition at line 174 of file sdlhelper.cpp.

178 {
179  return nullptr;
180 }

Referenced by ModernOpenGLGraphics::createGLContext().

◆ createThread()

SDL_Thread * SDL::createThread ( int(*)(void *)  fn,
const char *const  name,
void *const  data 
)

Definition at line 118 of file sdlhelper.cpp.

121 {
122  return SDL_CreateThread(fn, data);
123 }
uint32_t data

References data.

Referenced by Ea::Network::connect(), WhoIsOnline::download(), IPC::init(), and Net::Download::start().

◆ getAllVideoModes()

bool SDL::getAllVideoModes ( StringVect modeList)

< Surface is a full screen display

< Surface is in video memory

Definition at line 44 of file sdlhelper.cpp.

45 {
46  /* Get available fullscreen/hardware modes */
47  SDL_Rect *const *const modes = SDL_ListModes(nullptr,
48  SDL_FULLSCREEN | SDL_HWSURFACE);
49 
50 #ifdef ANDROID
51  const std::string modeString =
52  toString(CAST_S32(modes[0]->w)).append("x")
53  .append(toString(CAST_S32(modes[0]->h)));
54  logger->log("support mode: " + modeString);
55  modeList.push_back(modeString);
56  return true;
57 #else // ANDROID
58 
59  /* Check which modes are available */
60  if (modes == static_cast<SDL_Rect **>(nullptr))
61  {
62  logger->log1("No modes available");
63  return false;
64  }
65  else if (modes == reinterpret_cast<SDL_Rect **>(-1))
66  {
67  logger->log1("All resolutions available");
68  return true;
69  }
70  else
71  {
72  for (int i = 0; modes[i] != nullptr; ++ i)
73  {
74  const std::string modeString =
75  toString(CAST_S32(modes[i]->w)).append("x")
76  .append(toString(CAST_S32(modes[i]->h)));
77  logger->log("support mode: " + modeString);
78  modeList.push_back(modeString);
79  }
80  return true;
81  }
82 #endif // ANDROID
83 }
#define CAST_S32
Definition: cast.h:30
void log(const char *const log_text,...)
Definition: logger.cpp:269
void log1(const char *const log_text)
Definition: logger.cpp:238
Logger * logger
Definition: logger.cpp:89
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774

References CAST_S32, Logger::log(), Logger::log1(), logger, and Catch::toString().

Referenced by ModeListModel::ModeListModel(), and GraphicsManager::setVideoMode().

◆ getWindowWMInfo()

bool SDL::getWindowWMInfo ( const SDL_Surface *const  window,
SDL_SysWMinfo *const  info 
)

Definition at line 112 of file sdlhelper.cpp.

114 {
115  return SDL_GetWMInfo(info) != 0;
116 }
bool info(InputEvent &event)
Definition: commands.cpp:57

References Actions::info().

Referenced by GraphicsManager::detectPixelSize(), WindowManager::setIcon(), and GraphicsManager::updatePlanformExtensions().

◆ grabInput()

void SDL::grabInput ( const SDL_Surface *const  window,
const bool  grab 
)

Definition at line 97 of file sdlhelper.cpp.

98 {
99  SDL_WM_GrabInput(grab ? SDL_GRAB_ON : SDL_GRAB_OFF);
100 }

Referenced by WindowManager::applyGrabMode().

◆ initLogger()

void SDL::initLogger ( )

Definition at line 187 of file sdlhelper.cpp.

188 {
189 }

Referenced by Client::gameInit(), and main().

◆ LoadMUSOgg_RW()

Mix_Music * SDL::LoadMUSOgg_RW ( SDL_RWops *const  rw)

Definition at line 39 of file sdlmusichelper.cpp.

40 {
41  return Mix_LoadMUS_RW(rw);
42 }

Referenced by anonymous_namespace{musicloader.cpp}::ResourceLoader::load().

◆ makeCurrentContext()

void SDL::makeCurrentContext ( void *const  context)

Definition at line 182 of file sdlhelper.cpp.

183 {
184 }

Referenced by ModernOpenGLGraphics::createGLContext().

◆ MixOpenAudio()

int SDL::MixOpenAudio ( const int  frequency,
const uint16_t  format,
const int  nchannels,
const int  chunksize 
)

Definition at line 28 of file sdlmusichelper.cpp.

32 {
33  return Mix_OpenAudio(frequency,
34  format,
35  nchannels,
36  chunksize);
37 }

Referenced by SoundManager::init().

◆ PollEvent()

bool SDL::PollEvent ( SDL_Event *  event)

Definition at line 201 of file sdlhelper.cpp.

202 {
203  SDL_PumpEvents();
204  return SDL_PeepEvents(event,
205  1,
206  SDL_GETEVENT,
207  SDL_ALLEVENTS) > 0;
208 }

Referenced by EventsManager::handleEvents(), and EventsManager::handleGameEvents().

◆ setGamma()

void SDL::setGamma ( const SDL_Surface *const  window,
const float  gamma 
)

Definition at line 102 of file sdlhelper.cpp.

103 {
104  SDL_SetGamma(gamma, gamma, gamma);
105 }

Referenced by WindowManager::applyGamma().

◆ setLogLevel()

void SDL::setLogLevel ( const int  level)

Definition at line 191 of file sdlhelper.cpp.

192 {
193 }

Referenced by Client::gameInit().

◆ setVsync()

void SDL::setVsync ( const int  val)

Definition at line 107 of file sdlhelper.cpp.

108 {
109  SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, val);
110 }

Referenced by WindowManager::applyVSync().

◆ SetWindowIcon()

void SDL::SetWindowIcon ( const SDL_Surface *const  window,
SDL_Surface *const  icon 
)

Definition at line 91 of file sdlhelper.cpp.

93 {
94  SDL_WM_SetIcon(icon, nullptr);
95 }

Referenced by WindowManager::setIcon().

◆ SetWindowTitle()

void SDL::SetWindowTitle ( const SDL_Surface *const  window,
const char *const  title 
)

Definition at line 85 of file sdlhelper.cpp.

87 {
88  SDL_WM_SetCaption(title, nullptr);
89 }

Referenced by WindowManager::initTitle(), WindowManager::newChatMessage(), WindowManager::setIsMinimized(), and WindowManager::updateTitle().

◆ showCursor()

void SDL::showCursor ( const bool  show)

Definition at line 38 of file sdlsharedhelper.cpp.

39 {
40 #ifdef __native_client__
41  PP_MouseCursor_Type cursor;
42  if (show)
43  cursor = PP_MOUSECURSOR_TYPE_POINTER; // show default cursor
44  else
45  cursor = PP_MOUSECURSOR_TYPE_NONE; // hide cursor
46 
47  pp::MouseCursor::SetCursor(
48  pp::InstanceHandle(PSGetInstanceId()),
49  cursor);
50 #endif // __native_client__
51 
52  if (show)
53  SDL_ShowCursor(SDL_ENABLE);
54  else
55  SDL_ShowCursor(SDL_DISABLE);
56 }

Referenced by Gui::setUseCustomCursor().

◆ WaitThread()

void SDL::WaitThread ( SDL_Thread *const  thread)

Definition at line 195 of file sdlhelper.cpp.

196 {
197  if (thread != nullptr && SDL_GetThreadID(thread) != 0U)
198  SDL_WaitThread(thread, nullptr);
199 }

Referenced by WhoIsOnline::action(), Ea::Network::disconnect(), WhoIsOnline::download(), Net::Download::~Download(), IPC::~IPC(), and WhoIsOnline::~WhoIsOnline().