OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4AbstractApp Class Referenceabstract

#include <C4App.h>

Inheritance diagram for C4AbstractApp:
[legend]
Collaboration diagram for C4AbstractApp:
[legend]

Public Member Functions

 C4AbstractApp ()
 
 ~C4AbstractApp () override
 
virtual void Clear ()
 
bool Init (int argc, char *argv[])
 
void Run ()
 
virtual void Quit ()
 
bool GetIndexedDisplayMode (int32_t iIndex, int32_t *piXRes, int32_t *piYRes, int32_t *piBitDepth, int32_t *piRefreshRate, uint32_t iMonitor)
 
bool SetVideoMode (int iXRes, int iYRes, unsigned int iRefreshRate, unsigned int iMonitor, bool fFullScreen)
 
void RestoreVideoMode ()
 
bool DoScheduleProcs (int iTimeout) override
 
bool FlushMessages ()
 
bool Copy (const std::string &text, bool fClipboard=true)
 
std::string Paste (bool fClipboard=true)
 
bool IsClipboardFull (bool fClipboard=true)
 
virtual void OnCommand (const char *szCmd)=0
 
virtual void OnResolutionChanged (unsigned int iXRes, unsigned int iYRes)=0
 
virtual void OnKeyboardLayoutChanged ()=0
 
void NotifyUserIfInactive ()
 
void MessageDialog (const char *message)
 
const char * GetLastError ()
 
void Error (const char *m)
 
bool AssertMainThread ()
 
int getProcCnt () const
 
bool hasProc (StdSchedulerProc *pProc)
 
bool IsInManualLoop ()
 
void Set (StdSchedulerProc **ppProcs, int iProcCnt)
 
void Add (StdSchedulerProc *pProc)
 
void Remove (StdSchedulerProc *pProc)
 
void Added (StdSchedulerProc *pProc)
 
void Removing (StdSchedulerProc *pProc)
 
void Changed (StdSchedulerProc *pProc)
 
void StartOnCurrentThread ()
 
C4TimeMilliseconds GetNextTick (C4TimeMilliseconds tNow)
 
bool ScheduleProcs (int iTimeout=1000/36)
 
void UnBlock ()
 

Public Attributes

bool Active {false}
 
C4WindowpWindow {nullptr}
 
bool fQuitMsgReceived {false}
 
pthread_t MainThread
 

Protected Member Functions

virtual bool DoInit (int argc, char *argv[])=0
 
virtual void OnError (StdSchedulerProc *)
 

Protected Attributes

std::string sLastError
 
bool fDspModeSet {false}
 

Friends

class CStdGL
 
class CStdGLCtx
 
class C4Window
 
class C4GtkWindow
 

Detailed Description

Definition at line 57 of file C4App.h.

Constructor & Destructor Documentation

C4AbstractApp::C4AbstractApp ( )

Definition at line 72 of file C4AppSDL.cpp.

72  :
73  Active(false), pWindow(nullptr), fQuitMsgReceived(false),
74  // main thread
75 #ifdef HAVE_PTHREAD
76  MainThread (pthread_self()),
77 #endif
78 #ifdef _WIN32
79  idMainThread(0),
80 #endif
81  fDspModeSet(false)
82 {
83 }
pthread_t MainThread
Definition: C4App.h:128
bool Active
Definition: C4App.h:63
bool fQuitMsgReceived
Definition: C4App.h:81
bool fDspModeSet
Definition: C4App.h:157
C4Window * pWindow
Definition: C4App.h:80
C4AbstractApp::~C4AbstractApp ( )
overridedefault

Definition at line 37 of file C4AppT.cpp.

References StdScheduler::Remove().

38 {
39  Remove(&InProc);
40 }
void Remove(StdSchedulerProc *pProc)

Here is the call graph for this function:

Member Function Documentation

void StdScheduler::Add ( StdSchedulerProc pProc)
inherited

Definition at line 84 of file StdScheduler.cpp.

References StdScheduler::Added().

Referenced by C4GameLobby::ScenDesc::Activate(), C4Network2ResDlg::Activate(), C4GameOptionsList::Activate(), StdSchedulerThread::Add(), C4GameOverDlg::C4GameOverDlg(), C4GameSec1Timer::C4GameSec1Timer(), C4InteractiveThread::C4InteractiveThread(), C4Network2ClientListBox::C4Network2ClientListBox(), C4Network2ClientListDlg::C4Network2ClientListDlg(), C4Network2Stats::C4Network2Stats(), C4StartupNetDlg::C4StartupNetDlg(), C4GameLobby::Countdown::Countdown(), C4Application::DoInit(), C4GUI::InfoDialog::InfoDialog(), C4Network2::InitHost(), C4Network2::InitialConnect::InitialConnect(), C4Network2::InitLeague(), C4AulDebug::Listen(), C4GameLobby::MainDlg::MainDlg(), StdScheduler::Set(), C4Network2::StartStreaming(), and StdScheduler::StdScheduler().

85 {
86  // Already added to some scheduler
87  if (pProc->scheduler)
88  return;
89  // Add
90  procs.push_back(pProc);
91  pProc->scheduler = this;
92 
93  Added(pProc);
94 }
void Added(StdSchedulerProc *pProc)

Here is the call graph for this function:

Here is the caller graph for this function:

void StdScheduler::Added ( StdSchedulerProc pProc)
inherited

Definition at line 281 of file StdSchedulerMac.mm.

References SCHAdditions::assignAdditionForProc:, and SCHAdditions::requestAdditionsForScheduler:.

Referenced by StdScheduler::Add().

282 {
283  [[SCHAdditions requestAdditionsForScheduler:this] assignAdditionForProc:pProc];
284 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4AbstractApp::AssertMainThread ( )
inline

Definition at line 123 of file C4App.h.

References MainThread.

Referenced by Log(), LogSilent(), C4Surface::PageFlip(), CStdGL::PrepareRendering(), and ShaderLog().

124  {
125  assert(MainThread == pthread_self());
126  return MainThread == pthread_self();
127  }
pthread_t MainThread
Definition: C4App.h:128

Here is the caller graph for this function:

void StdScheduler::Changed ( StdSchedulerProc pProc)
inherited

Definition at line 294 of file StdSchedulerMac.mm.

References SCHAdditions::additionForProc:, SCHAddition::changed, and SCHAdditions::requestAdditionsForScheduler:.

295 {
296  [[[SCHAdditions requestAdditionsForScheduler:this] additionForProc:pProc] changed];
297 }

Here is the call graph for this function:

void C4AbstractApp::Clear ( )
virtual

Reimplemented in C4Application.

Definition at line 105 of file C4AppSDL.cpp.

Referenced by C4Application::Clear().

106 {
107  SDL_Quit();
108 }

Here is the caller graph for this function:

bool C4AbstractApp::Copy ( const std::string &  text,
bool  fClipboard = true 
)

Definition at line 33 of file C4AppMac.mm.

References Log().

Referenced by C4GUI::MessageDialog::KeyCopy().

34 {
35  NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
36  [pasteboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
37  NSString* string = [NSString stringWithCString:text.c_str() encoding:NSUTF8StringEncoding];
38  if (![pasteboard setString:string forType:NSStringPboardType])
39  {
40  Log("Writing to Cocoa pasteboard failed");
41  return false;
42  }
43  return true;
44 }
bool Log(const char *szMessage)
Definition: C4Log.cpp:202

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool C4AbstractApp::DoInit ( int  argc,
char *  argv[] 
)
protectedpure virtual

Implemented in C4Application.

Referenced by Init().

Here is the caller graph for this function:

bool C4AbstractApp::DoScheduleProcs ( int  iTimeout)
overridevirtual

Reimplemented from StdScheduler.

Definition at line 59 of file C4App.cpp.

References StdScheduler::DoScheduleProcs(), FlushMessages(), and fQuitMsgReceived.

60 {
61  // Always fail after quit message
63  return false;
64 #if defined(USE_SDL_MAINLOOP) || defined(USE_COCOA)
65  // Unfortunately, the SDL event loop needs to be polled
66  FlushMessages();
67 #endif
68 #ifdef WITH_QT_EDITOR
69  // Some places, for example the lobby, have a nested event processing loop.
70  // To prevent the editor from freezing, call the Qt event loop here.
71  if (iTimeout)
72  ProcessQtEvents();
73 #endif
74  return StdScheduler::DoScheduleProcs(iTimeout);
75 }
bool FlushMessages()
Definition: C4AppSDL.cpp:115
bool fQuitMsgReceived
Definition: C4App.h:81
virtual bool DoScheduleProcs(int iTimeout)

Here is the call graph for this function:

void C4AbstractApp::Error ( const char *  m)
inline

Definition at line 99 of file C4App.h.

References sLastError.

Referenced by C4Draw::Error(), and SetVideoMode().

99 { sLastError = m; }
std::string sLastError
Definition: C4App.h:156

Here is the caller graph for this function:

bool C4AbstractApp::FlushMessages ( )

Definition at line 115 of file C4AppSDL.cpp.

References fQuitMsgReceived.

Referenced by DoScheduleProcs(), C4Network2::FinalInit(), and C4Game::SetInitProgress().

116 {
117  // Always fail after quit message
118  if (fQuitMsgReceived)
119  return false;
120 
121  // Handle pending SDL messages
122  SDL_Event event;
123  while (SDL_PollEvent(&event))
124  {
125  HandleSDLEvent(event);
126  }
127  return true;
128 }
bool fQuitMsgReceived
Definition: C4App.h:81

Here is the caller graph for this function:

bool C4AbstractApp::GetIndexedDisplayMode ( int32_t  iIndex,
int32_t *  piXRes,
int32_t *  piYRes,
int32_t *  piBitDepth,
int32_t *  piRefreshRate,
uint32_t  iMonitor 
)

Definition at line 335 of file C4AppSDL.cpp.

Referenced by C4Application::ApplyResolutionConstraints().

336 {
337  if (!modeCount)
338  {
339  modeCount = SDL_GetNumDisplayModes(iMonitor);
340  }
341 
342  if (iIndex >= modeCount)
343  return false;
344 
345  SDL_DisplayMode mode;
346  SDL_GetDisplayMode(iMonitor, iIndex, &mode);
347  *piXRes = mode.w;
348  *piYRes = mode.h;
349  *piBitDepth = bits_per_pixel(mode.format);
350  if (piRefreshRate) *piRefreshRate = mode.refresh_rate;
351  return true;
352 }

Here is the caller graph for this function:

const char* C4AbstractApp::GetLastError ( )
inline

Definition at line 98 of file C4App.h.

References sLastError.

98 { return sLastError.c_str(); }
std::string sLastError
Definition: C4App.h:156
C4TimeMilliseconds StdScheduler::GetNextTick ( C4TimeMilliseconds  tNow)
inherited

Definition at line 120 of file StdScheduler.cpp.

References C4TimeMilliseconds::PositiveInfinity.

Referenced by Run(), and StdScheduler::ScheduleProcs().

121 {
123  for (auto proc : procs)
124  {
125  tProcTick = std::min(tProcTick, proc->GetNextTick(tNow));
126  }
127  return tProcTick;
128 }

Here is the caller graph for this function:

int StdScheduler::getProcCnt ( ) const
inlineinherited

Definition at line 245 of file StdScheduler.h.

Referenced by C4InteractiveThread::AddProc(), and C4InteractiveThread::RemoveProc().

245 { return procs.size()-1; } // ignore internal NoopNotifyProc

Here is the caller graph for this function:

bool StdScheduler::hasProc ( StdSchedulerProc pProc)
inlineinherited

Definition at line 246 of file StdScheduler.h.

Referenced by C4InteractiveThread::RemoveProc().

246 { return std::find(procs.begin(), procs.end(), pProc) != procs.end(); }

Here is the caller graph for this function:

bool C4AbstractApp::Init ( int  argc,
char *  argv[] 
)

Definition at line 87 of file C4AppSDL.cpp.

References DoInit(), and LogF().

Referenced by main().

88 {
89  // Set locale
90  setlocale(LC_ALL,"");
91 
92  if (SDL_Init(SDL_INIT_VIDEO) != 0)
93  {
94  LogF("SDL_Init: %s", SDL_GetError());
95  return false;
96  }
97 
98  //SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
99 
100  // Custom initialization
101  return DoInit (argc, argv);
102 }
virtual bool DoInit(int argc, char *argv[])=0
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:260

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4AbstractApp::IsClipboardFull ( bool  fClipboard = true)

Definition at line 57 of file C4AppMac.mm.

Referenced by C4GUI::Edit::OnContext().

58 {
59  return [[NSPasteboard generalPasteboard] availableTypeFromArray:[NSArray arrayWithObject:NSStringPboardType]];
60 }

Here is the caller graph for this function:

bool StdScheduler::IsInManualLoop ( )
inlineinherited

Definition at line 247 of file StdScheduler.h.

247 { return isInManualLoop; }
void C4AbstractApp::MessageDialog ( const char *  message)

Definition at line 62 of file C4AppMac.mm.

Referenced by C4Application::DoInit().

63 {
64  NSAlert* alert = [NSAlert alertWithMessageText:@"Fatal Error"
65  defaultButton:nil
66  alternateButton:nil
67  otherButton:nil
68  informativeTextWithFormat:@"%@",
69  [NSString stringWithUTF8String:message]
70  ];
71  [alert runModal];
72 }

Here is the caller graph for this function:

void C4AbstractApp::NotifyUserIfInactive ( )

Definition at line 89 of file C4App.cpp.

References Active, C4Window::FlashWindow(), and pWindow.

Referenced by C4Network2::DoLobby().

90 {
91 #ifdef _WIN32
92  if (!Active && pWindow) pWindow->FlashWindow();
93 #else
94  if (pWindow) pWindow->FlashWindow();
95 #endif
96 }
void FlashWindow()
Definition: C4AppMac.mm:74
bool Active
Definition: C4App.h:63
C4Window * pWindow
Definition: C4App.h:80

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void C4AbstractApp::OnCommand ( const char *  szCmd)
pure virtual

Implemented in C4Application.

virtual void StdScheduler::OnError ( StdSchedulerProc )
inlineprotectedvirtualinherited

Definition at line 268 of file StdScheduler.h.

268 { }
virtual void C4AbstractApp::OnKeyboardLayoutChanged ( )
pure virtual

Implemented in C4Application.

virtual void C4AbstractApp::OnResolutionChanged ( unsigned int  iXRes,
unsigned int  iYRes 
)
pure virtual

Implemented in C4Application.

Referenced by SetVideoMode().

Here is the caller graph for this function:

std::string C4AbstractApp::Paste ( bool  fClipboard = true)

Definition at line 46 of file C4AppMac.mm.

Referenced by C4GUI::Edit::MouseInput().

47 {
48  if (fClipboard)
49  {
50  NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
51  const char* chars = [[pasteboard stringForType:NSStringPboardType] cStringUsingEncoding:NSUTF8StringEncoding];
52  return chars;
53  }
54  return std::string();
55 }

Here is the caller graph for this function:

void C4AbstractApp::Quit ( )
virtual

Reimplemented in C4Application.

Definition at line 110 of file C4AppSDL.cpp.

References fQuitMsgReceived.

Referenced by C4Application::Quit().

111 {
112  fQuitMsgReceived = true;
113 }
bool fQuitMsgReceived
Definition: C4App.h:81

Here is the caller graph for this function:

void StdScheduler::Remove ( StdSchedulerProc pProc)
inherited

Definition at line 96 of file StdScheduler.cpp.

References StdScheduler::Removing().

Referenced by C4Application::Clear(), C4Network2::Clear(), StdScheduler::Clear(), C4GameLobby::ScenDesc::Deactivate(), C4Network2ResDlg::Deactivate(), C4GameOptionsList::Deactivate(), C4Network2::DeinitLeague(), StdSchedulerThread::Remove(), C4Network2::StopStreaming(), ~C4AbstractApp(), C4GameOverDlg::~C4GameOverDlg(), C4GameSec1Timer::~C4GameSec1Timer(), C4InteractiveThread::~C4InteractiveThread(), C4Network2ClientListBox::~C4Network2ClientListBox(), C4Network2ClientListDlg::~C4Network2ClientListDlg(), C4Network2Stats::~C4Network2Stats(), C4StartupNetDlg::~C4StartupNetDlg(), C4GameLobby::Countdown::~Countdown(), C4GUI::InfoDialog::~InfoDialog(), and C4GameLobby::MainDlg::~MainDlg().

97 {
98  // :o ?
99  if (pProc->scheduler != this)
100  return;
101  Removing(pProc);
102  pProc->scheduler = nullptr;
103  auto pos = std::find(procs.begin(), procs.end(), pProc);
104  if (pos != procs.end())
105  procs.erase(pos);
106 }
void Removing(StdSchedulerProc *pProc)

Here is the call graph for this function:

Here is the caller graph for this function:

void StdScheduler::Removing ( StdSchedulerProc pProc)
inherited

Definition at line 286 of file StdSchedulerMac.mm.

References SCHAdditions::requestAdditionsForScheduler:.

Referenced by StdScheduler::Remove().

287 {
288  auto x = [SCHAdditions requestAdditionsForScheduler:this];
289  [x removeAdditionForProc:pProc];
290  if ([x numberOfAdditions] == 0)
291  [SCHAdditions removeAdditions:x];
292 }

Here is the call graph for this function:

Here is the caller graph for this function:

void C4AbstractApp::RestoreVideoMode ( )

Definition at line 443 of file C4AppSDL.cpp.

References pWindow.

Referenced by C4Application::Clear().

444 {
445  if (pWindow && pWindow->window)
446  SDL_SetWindowFullscreen(pWindow->window, 0);
447 }
C4Window * pWindow
Definition: C4App.h:80

Here is the caller graph for this function:

void C4AbstractApp::Run ( )

Definition at line 26 of file C4App.cpp.

References Application, Clamp(), fQuitMsgReceived, StdScheduler::GetNextTick(), C4Application::isEditor, C4TimeMilliseconds::Now(), and StdScheduler::ScheduleProcs().

Referenced by main().

27 {
28 #ifdef WITH_QT_EDITOR
30  {
31  // Qt has its own event loop. Use a timer to call our own event handling whenever Qt is done
32  // with its events. The alternative (calling Qt's event handling from
33  // C4Console::Execute) is too slow, at least on Linux.
34  // FIXME: All of this should be happening in a background thread instead of on the UI thread
35  QTimer timer;
36  QObject::connect(&timer, &QTimer::timeout, [this, &timer]() {
37  ScheduleProcs(0);
38  if (fQuitMsgReceived)
39  {
40  QApplication::quit();
41  return;
42  }
43  auto now = C4TimeMilliseconds::Now();
44  auto next_tick = GetNextTick(now);
45  timer.setInterval(Clamp(next_tick - now, 0, 1000/36));
46  });
47  timer.setTimerType(Qt::PreciseTimer);
48  timer.start();
49  QApplication::exec();
50  return;
51  }
52 #endif
53 
54  // Main message loop
55  while (!fQuitMsgReceived)
56  ScheduleProcs();
57 }
C4TimeMilliseconds GetNextTick(C4TimeMilliseconds tNow)
T Clamp(T bval, T lbound, T rbound)
Definition: Standard.h:44
bool fQuitMsgReceived
Definition: C4App.h:81
bool ScheduleProcs(int iTimeout=1000/36)
C4Application Application
Definition: C4Globals.cpp:44
static C4TimeMilliseconds Now()

Here is the call graph for this function:

Here is the caller graph for this function:

bool StdScheduler::ScheduleProcs ( int  iTimeout = 1000/36)
inherited

Definition at line 130 of file StdScheduler.cpp.

References StdScheduler::DoScheduleProcs(), StdScheduler::GetNextTick(), and C4TimeMilliseconds::Now().

Referenced by C4AulDebug::DebugStep(), C4Network2::DoLobby(), C4GUI::Dialog::DoModal(), C4ScenarioListLoader::DoProcessCallback(), C4GUI::Dialog::Execute(), C4Network2::FinalInit(), C4Game::InitNetworkFromAddress(), C4Network2::LeaguePlrAuth(), C4Network2::LeagueStart(), C4AulDebug::Listen(), C4Network2::RetrieveRes(), Run(), and C4AppDelegate::suggestQuitting:.

131 {
132  // Needs at least one process to work properly
133  if (!procs.size()) return false;
134 
135  // Get timeout
137  C4TimeMilliseconds tProcTick = GetNextTick(tNow);
138  if (iTimeout == -1 || tNow + iTimeout > tProcTick)
139  {
140  iTimeout = std::max<decltype(iTimeout)>(tProcTick - tNow, 0);
141  }
142 
143  bool old = isInManualLoop;
144  isInManualLoop = true;
145  bool res = DoScheduleProcs(iTimeout);
146  isInManualLoop = old;
147  return res;
148 }
C4TimeMilliseconds GetNextTick(C4TimeMilliseconds tNow)
virtual bool DoScheduleProcs(int iTimeout)
static C4TimeMilliseconds Now()

Here is the call graph for this function:

Here is the caller graph for this function:

void StdScheduler::Set ( StdSchedulerProc **  ppProcs,
int  iProcCnt 
)
inherited

Definition at line 75 of file StdScheduler.cpp.

References StdScheduler::Add(), and StdScheduler::Clear().

Referenced by StdSchedulerThread::Set().

76 {
77  // Remove previous data
78  Clear();
79  // Copy new
80  for (int i = 0; i < inProcCnt; i++)
81  Add(ppnProcs[i]);
82 }
void Add(StdSchedulerProc *pProc)

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4AbstractApp::SetVideoMode ( int  iXRes,
int  iYRes,
unsigned int  iRefreshRate,
unsigned int  iMonitor,
bool  fFullScreen 
)

Definition at line 354 of file C4AppSDL.cpp.

References C4Draw::COLOR_DEPTH, Error(), LogF(), OnResolutionChanged(), pWindow, and C4Window::SetSize().

Referenced by C4Application::DoInit(), FullScreenWinProc(), and C4Application::GameTick().

355 {
356  int res;
357  if (!fFullScreen)
358  {
359  if (iXRes == -1)
360  {
361  SDL_DisplayMode desktop_mode;
362  res = SDL_GetDesktopDisplayMode(iMonitor, &desktop_mode);
363  if (res)
364  {
365  Error(SDL_GetError());
366  LogF("SDL_GetDesktopDisplayMode: %s", SDL_GetError());
367  return false;
368  }
369 
370  iXRes = desktop_mode.w;
371  iYRes = desktop_mode.h;
372  }
373 
374  res = SDL_SetWindowFullscreen(pWindow->window, 0);
375  if (res)
376  {
377  Error(SDL_GetError());
378  LogF("SDL_SetWindowFullscreen: %s", SDL_GetError());
379  return false;
380  }
381 
382  pWindow->SetSize(iXRes, iYRes);
383  OnResolutionChanged(iXRes, iYRes);
384  return true;
385  }
386  SDL_DisplayMode mode;
387  if (iXRes < 0 || iYRes < 0)
388  {
389  res = SDL_SetWindowFullscreen(pWindow->window, SDL_WINDOW_FULLSCREEN_DESKTOP);
390  if (res)
391  {
392  Error(SDL_GetError());
393  LogF("SDL_SetWindowFullscreen: %s", SDL_GetError());
394  return false;
395  }
396  res = SDL_GetDesktopDisplayMode(iMonitor, &mode);
397  if (res)
398  {
399  Error(SDL_GetError());
400  LogF("SDL_GetDesktopDisplayMode: %s", SDL_GetError());
401  return false;
402  }
403  OnResolutionChanged(mode.w, mode.h);
404  return true;
405  }
406 
407  for (int i = 0; i < modeCount; ++i)
408  {
409  res = SDL_GetDisplayMode(iMonitor, i, &mode);
410 
411  if (res)
412  {
413  Error(SDL_GetError());
414  LogF("SDL_GetDisplayMode: %s", SDL_GetError());
415  return false;
416  }
417 
418  if (mode.w == iXRes && mode.h == iYRes && (RefreshRate == 0 || mode.refresh_rate == RefreshRate) && bits_per_pixel(mode.format) == C4Draw::COLOR_DEPTH)
419  {
420  res = SDL_SetWindowDisplayMode(pWindow->window, &mode);
421  if (res)
422  {
423  Error(SDL_GetError());
424  LogF("SDL_SetWindowDisplayMode: %s", SDL_GetError());
425  return false;
426  }
427  res = SDL_SetWindowFullscreen(pWindow->window, SDL_WINDOW_FULLSCREEN);
428  if (res)
429  {
430  Error(SDL_GetError());
431  LogF("SDL_SetWindowFullscreen: %s", SDL_GetError());
432  return false;
433  }
434  OnResolutionChanged(mode.w, mode.h);
435  return true;
436  }
437  }
438 
439  Error("No such resolution available");
440  return false;
441 }
virtual void OnResolutionChanged(unsigned int iXRes, unsigned int iYRes)=0
static constexpr int COLOR_DEPTH
Definition: C4Draw.h:89
void SetSize(unsigned int cx, unsigned int cy)
Definition: C4AppT.cpp:110
void Error(const char *m)
Definition: C4App.h:99
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:260
C4Window * pWindow
Definition: C4App.h:80

Here is the call graph for this function:

Here is the caller graph for this function:

void StdScheduler::StartOnCurrentThread ( )
inherited

Definition at line 276 of file StdSchedulerMac.mm.

References SCHAdditions::requestAdditionsForScheduler:, and SCHAdditions::start.

277 {
278  [[SCHAdditions requestAdditionsForScheduler:this] start];
279 }

Here is the call graph for this function:

void StdScheduler::UnBlock ( )
inherited

Definition at line 150 of file StdScheduler.cpp.

Referenced by StdSchedulerThread::Stop().

151 {
152  Unblocker.Notify();
153 }

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class C4GtkWindow
friend

Definition at line 163 of file C4App.h.

friend class C4Window
friend

Definition at line 162 of file C4App.h.

friend class CStdGL
friend

Definition at line 160 of file C4App.h.

friend class CStdGLCtx
friend

Definition at line 161 of file C4App.h.

Member Data Documentation

bool C4AbstractApp::fDspModeSet {false}
protected

Definition at line 157 of file C4App.h.

bool C4AbstractApp::fQuitMsgReceived {false}
pthread_t C4AbstractApp::MainThread

Definition at line 128 of file C4App.h.

Referenced by AssertMainThread().

std::string C4AbstractApp::sLastError
protected

Definition at line 156 of file C4App.h.

Referenced by Error(), and GetLastError().


The documentation for this class was generated from the following files: