Bladeren bron

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

legacy
Sam Hocevar sam 12 jaren geleden
bovenliggende
commit
f44e3e323b
14 gewijzigde bestanden met toevoegingen van 68 en 67 verwijderingen
  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 Bestand weergeven

@@ -70,14 +70,19 @@ Application::Application(char const *name, ivec2 resolution, float 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()


+ 5
- 1
src/application/application.h Bestand weergeven

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

bool MustTick();
void Tick();

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

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

private:
ApplicationData *data;


+ 4
- 7
src/eglapp.cpp Bestand weergeven

@@ -267,16 +267,13 @@ void EglApp::ShowPointer(bool 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__
eglSwapBuffers(data->egl_dpy, data->egl_surf);
eglSwapBuffers(data->egl_dpy, data->egl_surf);
#endif
}
}

EglApp::~EglApp()


+ 1
- 1
src/eglapp.h Bestand weergeven

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

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

private:
EglAppData *data;


+ 12
- 10
src/platform/android/androidapp.cpp Bestand weergeven

@@ -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
* called. Then we sit here forever, the Java layer is in charge of
* 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)


+ 1
- 1
src/platform/android/androidapp.h Bestand weergeven

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

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

static void *MainRun(void *data);



+ 8
- 6
src/platform/nacl/nacl-app.cpp Bestand weergeven

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

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

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

NaClApp::~NaClApp()


+ 1
- 1
src/platform/nacl/nacl-app.h Bestand weergeven

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

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

private:
NaClAppData *data;


+ 6
- 9
src/platform/ps3/ps3app.cpp Bestand weergeven

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

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

Ps3App::~Ps3App()


+ 1
- 1
src/platform/ps3/ps3app.h Bestand weergeven

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

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

private:
Ps3AppData *data;


+ 14
- 17
src/platform/sdl/sdlapp.cpp Bestand weergeven

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

void SdlApp::Run()
void SdlApp::Tick()
{
while (!Ticker::Finished())
{
#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
/* 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_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
SDL_GL_SwapBuffers();
SDL_GL_SwapBuffers();
# endif
#endif
}
}

SdlApp::~SdlApp()


+ 1
- 1
src/platform/sdl/sdlapp.h Bestand weergeven

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

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

private:
SdlAppData *data;


+ 4
- 7
src/platform/xbox/xboxapp.cpp Bestand weergeven

@@ -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
g_d3ddevice->Present(NULL, NULL, NULL, NULL);
g_d3ddevice->Present(NULL, NULL, NULL, NULL);
#endif
}
}

XboxApp::~XboxApp()


+ 1
- 1
src/platform/xbox/xboxapp.h Bestand weergeven

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

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

private:
XboxAppData *data;


Laden…
Annuleren
Opslaan