Parcourir la source

core: you can now while(app.MustTick()) { Tick(); } instead of app.Run().

legacy
Sam Hocevar sam il y a 12 ans
Parent
révision
f44e3e323b
14 fichiers modifiés avec 68 ajouts et 67 suppressions
  1. +9
    -4
      src/application/application.cpp
  2. +5
    -1
      src/application/application.h
  3. +4
    -7
      src/eglapp.cpp
  4. +1
    -1
      src/eglapp.h
  5. +12
    -10
      src/platform/android/androidapp.cpp
  6. +1
    -1
      src/platform/android/androidapp.h
  7. +8
    -6
      src/platform/nacl/nacl-app.cpp
  8. +1
    -1
      src/platform/nacl/nacl-app.h
  9. +6
    -9
      src/platform/ps3/ps3app.cpp
  10. +1
    -1
      src/platform/ps3/ps3app.h
  11. +14
    -17
      src/platform/sdl/sdlapp.cpp
  12. +1
    -1
      src/platform/sdl/sdlapp.h
  13. +4
    -7
      src/platform/xbox/xboxapp.cpp
  14. +1
    -1
      src/platform/xbox/xboxapp.h

+ 9
- 4
src/application/application.cpp Voir le fichier

@@ -70,14 +70,19 @@ Application::Application(char const *name, ivec2 resolution, float framerate)
data = new ApplicationData(name, resolution, framerate); data = new ApplicationData(name, resolution, framerate);
} }


void Application::ShowPointer(bool show)
bool Application::MustTick()
{ {
data->app.ShowPointer(show);
return !Ticker::Finished();
} }


void Application::Run()
void Application::Tick()
{ {
data->app.Run();
data->app.Tick();
}

void Application::ShowPointer(bool show)
{
data->app.ShowPointer(show);
} }


Application::~Application() Application::~Application()


+ 5
- 1
src/application/application.h Voir le fichier

@@ -27,8 +27,12 @@ public:
Application(char const *name, ivec2 resolution, float framerate); Application(char const *name, ivec2 resolution, float framerate);
~Application(); ~Application();


bool MustTick();
void Tick();

void Run() { while(MustTick()) Tick(); }

void ShowPointer(bool show); void ShowPointer(bool show);
void Run();


private: private:
ApplicationData *data; ApplicationData *data;


+ 4
- 7
src/eglapp.cpp Voir le fichier

@@ -267,16 +267,13 @@ void EglApp::ShowPointer(bool show)
(void)show; (void)show;
} }


void EglApp::Run()
void EglApp::Tick()
{ {
while (!Ticker::Finished())
{
/* Tick the renderer, show the frame and clamp to desired framerate. */
Ticker::TickDraw();
/* Tick the renderer, show the frame and clamp to desired framerate. */
Ticker::TickDraw();
#if defined USE_EGL && !defined __ANDROID__ #if defined USE_EGL && !defined __ANDROID__
eglSwapBuffers(data->egl_dpy, data->egl_surf);
eglSwapBuffers(data->egl_dpy, data->egl_surf);
#endif #endif
}
} }


EglApp::~EglApp() EglApp::~EglApp()


+ 1
- 1
src/eglapp.h Voir le fichier

@@ -30,7 +30,7 @@ public:
virtual ~EglApp(); virtual ~EglApp();


void ShowPointer(bool show); void ShowPointer(bool show);
void Run();
void Tick();


private: private:
EglAppData *data; EglAppData *data;


+ 12
- 10
src/platform/android/androidapp.cpp Voir le fichier

@@ -46,22 +46,24 @@ void AndroidApp::ShowPointer(bool show)
{ {
} }


/* This is a fake Run() method. We just wait until we're called and
/* This is a fake Tick() method. We just wait until we're called and
* signal nativeInit() that all the user's initialisation code was * signal nativeInit() that all the user's initialisation code was
* called. Then we sit here forever, the Java layer is in charge of * called. Then we sit here forever, the Java layer is in charge of
* calling TickDraw(). */ * calling TickDraw(). */
void AndroidApp::Run()
void AndroidApp::Tick()
{ {
g_main_queue.Push(1);
g_main_queue.Push(1);

while (!Ticker::Finished())
static int init = 0;
if (!init)
{ {
/* Do nothing while the real render thread does the job. The
* real stuff happens in nativeRender() */
Timer t;
t.Wait(0.5f);
init = 1;
g_main_queue.Push(1);
g_main_queue.Push(1);
} }

/* Do nothing while the real render thread does the job. The
* real stuff happens in nativeRender() */
Timer t;
t.Wait(0.5f);
} }


void *AndroidApp::MainRun(void *data) void *AndroidApp::MainRun(void *data)


+ 1
- 1
src/platform/android/androidapp.h Voir le fichier

@@ -30,7 +30,7 @@ public:
virtual ~AndroidApp(); virtual ~AndroidApp();


void ShowPointer(bool show); void ShowPointer(bool show);
void Run();
void Tick();


static void *MainRun(void *data); static void *MainRun(void *data);




+ 8
- 6
src/platform/nacl/nacl-app.cpp Voir le fichier

@@ -50,15 +50,17 @@ void NaClApp::ShowPointer(bool show)
; ;
} }


void NaClApp::Run()
void NaClApp::Tick()
{ {
/* The caller should run forever */
#if defined __native_client__ #if defined __native_client__
NaClInstance::MainSignal();
static int init = 0;
if (!init)
{
NaClInstance::MainSignal();
init = 1;
}
#endif #endif

/* Wait forever */
Queue<int, 1> q;
q.Pop();
} }


NaClApp::~NaClApp() NaClApp::~NaClApp()


+ 1
- 1
src/platform/nacl/nacl-app.h Voir le fichier

@@ -30,7 +30,7 @@ public:
virtual ~NaClApp(); virtual ~NaClApp();


void ShowPointer(bool show); void ShowPointer(bool show);
void Run();
void Tick();


private: private:
NaClAppData *data; NaClAppData *data;


+ 6
- 9
src/platform/ps3/ps3app.cpp Voir le fichier

@@ -114,20 +114,17 @@ void Ps3App::ShowPointer(bool show)
; ;
} }


void Ps3App::Run()
void Ps3App::Tick()
{ {
while (!Ticker::Finished())
{
/* Tick the renderer, show the frame and clamp to desired framerate. */
Ticker::TickDraw();
/* Tick the renderer, show the frame and clamp to desired framerate. */
Ticker::TickDraw();


#if defined __CELLOS_LV2__ #if defined __CELLOS_LV2__
psglSwap();
psglSwap();


/* Check if exit callback was called */
cellSysutilCheckCallback();
/* Check if exit callback was called */
cellSysutilCheckCallback();
#endif #endif
}
} }


Ps3App::~Ps3App() Ps3App::~Ps3App()


+ 1
- 1
src/platform/ps3/ps3app.h Voir le fichier

@@ -30,7 +30,7 @@ public:
virtual ~Ps3App(); virtual ~Ps3App();


void ShowPointer(bool show); void ShowPointer(bool show);
void Run();
void Tick();


private: private:
Ps3AppData *data; Ps3AppData *data;


+ 14
- 17
src/platform/sdl/sdlapp.cpp Voir le fichier

@@ -109,31 +109,28 @@ void SdlApp::ShowPointer(bool show)
#endif #endif
} }


void SdlApp::Run()
void SdlApp::Tick()
{ {
while (!Ticker::Finished())
{
#if defined USE_SDL && defined USE_D3D9 #if defined USE_SDL && defined USE_D3D9
HRESULT hr;
hr = g_d3ddevice->BeginScene();
if (FAILED(hr))
Abort();
HRESULT hr;
hr = g_d3ddevice->BeginScene();
if (FAILED(hr))
Abort();
#endif #endif
/* Tick the renderer, show the frame and clamp to desired framerate. */
Ticker::TickDraw();
/* Tick the renderer, show the frame and clamp to desired framerate. */
Ticker::TickDraw();
#if defined USE_SDL #if defined USE_SDL
# if defined USE_D3D9 # if defined USE_D3D9
hr = g_d3ddevice->EndScene();
if (FAILED(hr))
Abort();
hr = g_d3ddevice->Present(NULL, NULL, NULL, NULL);
if (FAILED(hr))
Abort();
hr = g_d3ddevice->EndScene();
if (FAILED(hr))
Abort();
hr = g_d3ddevice->Present(NULL, NULL, NULL, NULL);
if (FAILED(hr))
Abort();
# else # else
SDL_GL_SwapBuffers();
SDL_GL_SwapBuffers();
# endif # endif
#endif #endif
}
} }


SdlApp::~SdlApp() SdlApp::~SdlApp()


+ 1
- 1
src/platform/sdl/sdlapp.h Voir le fichier

@@ -30,7 +30,7 @@ public:
virtual ~SdlApp(); virtual ~SdlApp();


void ShowPointer(bool show); void ShowPointer(bool show);
void Run();
void Tick();


private: private:
SdlAppData *data; SdlAppData *data;


+ 4
- 7
src/platform/xbox/xboxapp.cpp Voir le fichier

@@ -61,17 +61,14 @@ void XboxApp::ShowPointer(bool show)
; ;
} }


void XboxApp::Run()
void XboxApp::Tick()
{ {
while (!Ticker::Finished())
{
/* Tick the renderer, show the frame and clamp to desired framerate. */
Ticker::TickDraw();
/* Tick the renderer, show the frame and clamp to desired framerate. */
Ticker::TickDraw();


#if defined _XBOX #if defined _XBOX
g_d3ddevice->Present(NULL, NULL, NULL, NULL);
g_d3ddevice->Present(NULL, NULL, NULL, NULL);
#endif #endif
}
} }


XboxApp::~XboxApp() XboxApp::~XboxApp()


+ 1
- 1
src/platform/xbox/xboxapp.h Voir le fichier

@@ -30,7 +30,7 @@ public:
virtual ~XboxApp(); virtual ~XboxApp();


void ShowPointer(bool show); void ShowPointer(bool show);
void Run();
void Tick();


private: private:
XboxAppData *data; XboxAppData *data;


Chargement…
Annuler
Enregistrer