@@ -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() | ||||
@@ -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; | ||||
@@ -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() | ||||
@@ -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; | ||||
@@ -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) | ||||
@@ -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); | ||||
@@ -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() | ||||
@@ -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; | ||||
@@ -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() | ||||
@@ -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; | ||||
@@ -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() | ||||
@@ -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; | ||||
@@ -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() | ||||
@@ -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; | ||||