OpenClonk
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::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 fQuitMsgReceived
Definition: C4App.h:81
bool Active
Definition: C4App.h:63
bool fDspModeSet
Definition: C4App.h:157
C4Window * pWindow
Definition: C4App.h:80

◆ ~C4AbstractApp()

C4AbstractApp::~C4AbstractApp ( )
overridedefault

Definition at line 40 of file C4AppT.cpp.

41 {
42  Remove(&InProc);
43 }
void Remove(StdSchedulerProc *pProc)

References StdScheduler::Remove().

Here is the call graph for this function:

Member Function Documentation

◆ Add()

void StdScheduler::Add ( StdSchedulerProc pProc)
inherited

Definition at line 84 of file StdScheduler.cpp.

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)

References StdScheduler::Added().

Referenced by C4GameLobby::ScenDesc::Activate(), C4GameOptionsList::Activate(), C4Network2ResDlg::Activate(), StdSchedulerThread::Add(), C4GameOverDlg::C4GameOverDlg(), C4GameSec1Timer::C4GameSec1Timer(), C4InteractiveThread::C4InteractiveThread(), C4Network2ClientListBox::C4Network2ClientListBox(), C4Network2ClientListDlg::C4Network2ClientListDlg(), C4Network2Stats::C4Network2Stats(), C4StartupModsDlg::C4StartupModsDlg(), C4StartupModsDownloader::C4StartupModsDownloader(), 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Added()

void StdScheduler::Added ( StdSchedulerProc pProc)
inherited

Definition at line 281 of file StdSchedulerMac.mm.

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

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

Referenced by StdScheduler::Add().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AssertMainThread()

bool C4AbstractApp::AssertMainThread ( )
inline

Definition at line 123 of file C4App.h.

124  {
125  assert(MainThread == pthread_self());
126  return MainThread == pthread_self();
127  }

References MainThread.

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

Here is the caller graph for this function:

◆ Changed()

void StdScheduler::Changed ( StdSchedulerProc pProc)
inherited

Definition at line 294 of file StdSchedulerMac.mm.

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

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

Here is the call graph for this function:

◆ Clear()

void C4AbstractApp::Clear ( )
virtual

Reimplemented in C4Application.

Definition at line 105 of file C4AppSDL.cpp.

106 {
107  SDL_Quit();
108 }

Referenced by C4Application::Clear().

Here is the caller graph for this function:

◆ Copy()

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

Definition at line 34 of file C4AppMac.mm.

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

References Log(), and C4ScriptGuiWindowPropertyName::text.

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoInit()

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

Implemented in C4Application.

Referenced by Init().

Here is the caller graph for this function:

◆ DoScheduleProcs()

bool C4AbstractApp::DoScheduleProcs ( int  iTimeout)
overridevirtual

Reimplemented from StdScheduler.

Definition at line 59 of file C4App.cpp.

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
virtual bool DoScheduleProcs(int iTimeout)

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

Here is the call graph for this function:

◆ Error()

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

Definition at line 99 of file C4App.h.

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

References sLastError.

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

Here is the caller graph for this function:

◆ FlushMessages()

bool C4AbstractApp::FlushMessages ( )

Definition at line 115 of file C4AppSDL.cpp.

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 }

References fQuitMsgReceived.

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

Here is the caller graph for this function:

◆ GetIndexedDisplayMode()

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.

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 }

Referenced by C4Application::ApplyResolutionConstraints().

Here is the caller graph for this function:

◆ GetLastError()

const char* C4AbstractApp::GetLastError ( )
inline

Definition at line 98 of file C4App.h.

98 { return sLastError.c_str(); }

References sLastError.

◆ GetNextTick()

C4TimeMilliseconds StdScheduler::GetNextTick ( C4TimeMilliseconds  tNow)
inherited

Definition at line 120 of file StdScheduler.cpp.

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

References C4TimeMilliseconds::PositiveInfinity.

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

Here is the caller graph for this function:

◆ getProcCnt()

int StdScheduler::getProcCnt ( ) const
inlineinherited

Definition at line 245 of file StdScheduler.h.

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

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

Here is the caller graph for this function:

◆ hasProc()

bool StdScheduler::hasProc ( StdSchedulerProc pProc)
inlineinherited

Definition at line 246 of file StdScheduler.h.

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

Referenced by C4InteractiveThread::RemoveProc().

Here is the caller graph for this function:

◆ Init()

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

Definition at line 87 of file C4AppSDL.cpp.

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 }
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:262
virtual bool DoInit(int argc, char *argv[])=0

References DoInit(), and LogF().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsClipboardFull()

bool C4AbstractApp::IsClipboardFull ( bool  fClipboard = true)

Definition at line 58 of file C4AppMac.mm.

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

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

Here is the caller graph for this function:

◆ IsInManualLoop()

bool StdScheduler::IsInManualLoop ( )
inlineinherited

Definition at line 247 of file StdScheduler.h.

247 { return isInManualLoop; }

◆ MessageDialog()

void C4AbstractApp::MessageDialog ( const char *  message)

Definition at line 63 of file C4AppMac.mm.

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

Referenced by C4Application::DoInit().

Here is the caller graph for this function:

◆ NotifyUserIfInactive()

void C4AbstractApp::NotifyUserIfInactive ( )

Definition at line 89 of file C4App.cpp.

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:75

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

Referenced by C4Network2::DoLobby().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnCommand()

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

Implemented in C4Application.

◆ OnError()

virtual void StdScheduler::OnError ( StdSchedulerProc )
inlineprotectedvirtualinherited

Definition at line 268 of file StdScheduler.h.

268 { }

◆ OnKeyboardLayoutChanged()

virtual void C4AbstractApp::OnKeyboardLayoutChanged ( )
pure virtual

Implemented in C4Application.

◆ OnResolutionChanged()

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:

◆ Paste()

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

Definition at line 47 of file C4AppMac.mm.

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

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

Here is the caller graph for this function:

◆ Quit()

void C4AbstractApp::Quit ( )
virtual

Reimplemented in C4Application.

Definition at line 110 of file C4AppSDL.cpp.

111 {
112  fQuitMsgReceived = true;
113 }

References fQuitMsgReceived.

Referenced by C4Application::Quit().

Here is the caller graph for this function:

◆ Remove()

void StdScheduler::Remove ( StdSchedulerProc pProc)
inherited

Definition at line 96 of file StdScheduler.cpp.

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)

References StdScheduler::Removing().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Removing()

void StdScheduler::Removing ( StdSchedulerProc pProc)
inherited

Definition at line 286 of file StdSchedulerMac.mm.

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

References SCHAdditions::requestAdditionsForScheduler:.

Referenced by StdScheduler::Remove().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RestoreVideoMode()

void C4AbstractApp::RestoreVideoMode ( )

Definition at line 443 of file C4AppSDL.cpp.

444 {
445  if (pWindow && pWindow->window)
446  SDL_SetWindowFullscreen(pWindow->window, 0);
447 }

References pWindow.

Referenced by C4Application::Clear().

Here is the caller graph for this function:

◆ Run()

void C4AbstractApp::Run ( )

Definition at line 26 of file C4App.cpp.

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 }
C4Application Application
Definition: C4Globals.cpp:44
T Clamp(T bval, T lbound, T rbound)
Definition: Standard.h:44
static C4TimeMilliseconds Now()
bool ScheduleProcs(int iTimeout=1000/36)
C4TimeMilliseconds GetNextTick(C4TimeMilliseconds tNow)

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

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ScheduleProcs()

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

Definition at line 130 of file StdScheduler.cpp.

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 }

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(), and Run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Set()

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

Definition at line 75 of file StdScheduler.cpp.

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)

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

Referenced by StdSchedulerThread::Set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetVideoMode()

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

Definition at line 354 of file C4AppSDL.cpp.

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
void Error(const char *m)
Definition: C4App.h:99
static constexpr int COLOR_DEPTH
Definition: C4Draw.h:89
void SetSize(unsigned int cx, unsigned int cy)
Definition: C4AppT.cpp:113

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StartOnCurrentThread()

void StdScheduler::StartOnCurrentThread ( )
inherited

Definition at line 276 of file StdSchedulerMac.mm.

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

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

Here is the call graph for this function:

◆ UnBlock()

void StdScheduler::UnBlock ( )
inherited

Definition at line 150 of file StdScheduler.cpp.

151 {
152  Unblocker.Notify();
153 }

Referenced by StdSchedulerThread::Stop().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ C4GtkWindow

friend class C4GtkWindow
friend

Definition at line 163 of file C4App.h.

◆ C4Window

friend class C4Window
friend

Definition at line 162 of file C4App.h.

◆ CStdGL

friend class CStdGL
friend

Definition at line 160 of file C4App.h.

◆ CStdGLCtx

friend class CStdGLCtx
friend

Definition at line 161 of file C4App.h.

Member Data Documentation

◆ Active

◆ fDspModeSet

bool C4AbstractApp::fDspModeSet {false}
protected

Definition at line 157 of file C4App.h.

◆ fQuitMsgReceived

bool C4AbstractApp::fQuitMsgReceived {false}

Definition at line 81 of file C4App.h.

Referenced by DoScheduleProcs(), FlushMessages(), Quit(), and Run().

◆ MainThread

pthread_t C4AbstractApp::MainThread

Definition at line 128 of file C4App.h.

Referenced by AssertMainThread().

◆ pWindow

◆ sLastError

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: