Changeset 2222


Ignore:
Timestamp:
Jan 15, 2013, 11:41:52 PM (7 years ago)
Author:
sam
Message:

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

Location:
trunk/src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/application/application.cpp

    r2216 r2222  
    7171}
    7272
     73bool Application::MustTick()
     74{
     75    return !Ticker::Finished();
     76}
     77
     78void Application::Tick()
     79{
     80    data->app.Tick();
     81}
     82
    7383void Application::ShowPointer(bool show)
    7484{
    7585    data->app.ShowPointer(show);
    76 }
    77 
    78 void Application::Run()
    79 {
    80     data->app.Run();
    8186}
    8287
  • trunk/src/application/application.h

    r2183 r2222  
    2828    ~Application();
    2929
     30    bool MustTick();
     31    void Tick();
     32
     33    void Run() { while(MustTick()) Tick(); }
     34
    3035    void ShowPointer(bool show);
    31     void Run();
    3236
    3337private:
  • trunk/src/eglapp.cpp

    r2183 r2222  
    268268}
    269269
    270 void EglApp::Run()
    271 {
    272     while (!Ticker::Finished())
    273     {
    274         /* Tick the renderer, show the frame and clamp to desired framerate. */
    275         Ticker::TickDraw();
    276 #if defined USE_EGL && !defined __ANDROID__
    277         eglSwapBuffers(data->egl_dpy, data->egl_surf);
    278 #endif
    279     }
     270void EglApp::Tick()
     271{
     272    /* Tick the renderer, show the frame and clamp to desired framerate. */
     273    Ticker::TickDraw();
     274#if defined USE_EGL && !defined __ANDROID__
     275    eglSwapBuffers(data->egl_dpy, data->egl_surf);
     276#endif
    280277}
    281278
  • trunk/src/eglapp.h

    r2183 r2222  
    3131
    3232    void ShowPointer(bool show);
    33     void Run();
     33    void Tick();
    3434
    3535private:
  • trunk/src/platform/android/androidapp.cpp

    r2183 r2222  
    4747}
    4848
    49 /* This is a fake Run() method. We just wait until we're called and
     49/* This is a fake Tick() method. We just wait until we're called and
    5050 * signal nativeInit() that all the user's initialisation code was
    5151 * called. Then we sit here forever, the Java layer is in charge of
    5252 * calling TickDraw(). */
    53 void AndroidApp::Run()
     53void AndroidApp::Tick()
    5454{
    55     g_main_queue.Push(1);
    56     g_main_queue.Push(1);
     55    static int init = 0;
     56    if (!init)
     57    {
     58        init = 1;
     59        g_main_queue.Push(1);
     60        g_main_queue.Push(1);
     61    }
    5762
    58     while (!Ticker::Finished())
    59     {
    60         /* Do nothing while the real render thread does the job. The
    61          * real stuff happens in nativeRender() */
    62         Timer t;
    63         t.Wait(0.5f);
    64     }
     63    /* Do nothing while the real render thread does the job. The
     64     * real stuff happens in nativeRender() */
     65    Timer t;
     66    t.Wait(0.5f);
    6567}
    6668
  • trunk/src/platform/android/androidapp.h

    r2183 r2222  
    3131
    3232    void ShowPointer(bool show);
    33     void Run();
     33    void Tick();
    3434
    3535    static void *MainRun(void *data);
  • trunk/src/platform/nacl/nacl-app.cpp

    r2183 r2222  
    5151}
    5252
    53 void NaClApp::Run()
     53void NaClApp::Tick()
    5454{
     55    /* The caller should run forever */
    5556#if defined __native_client__
    56     NaClInstance::MainSignal();
     57    static int init = 0;
     58    if (!init)
     59    {
     60        NaClInstance::MainSignal();
     61        init = 1;
     62    }
    5763#endif
    58 
    59     /* Wait forever */
    60     Queue<int, 1> q;
    61     q.Pop();
    6264}
    6365
  • trunk/src/platform/nacl/nacl-app.h

    r2183 r2222  
    3131
    3232    void ShowPointer(bool show);
    33     void Run();
     33    void Tick();
    3434
    3535private:
  • trunk/src/platform/ps3/ps3app.cpp

    r2183 r2222  
    115115}
    116116
    117 void Ps3App::Run()
     117void Ps3App::Tick()
    118118{
    119     while (!Ticker::Finished())
    120     {
    121         /* Tick the renderer, show the frame and clamp to desired framerate. */
    122         Ticker::TickDraw();
     119    /* Tick the renderer, show the frame and clamp to desired framerate. */
     120    Ticker::TickDraw();
    123121
    124122#if defined __CELLOS_LV2__
    125         psglSwap();
     123    psglSwap();
    126124
    127         /* Check if exit callback was called */
    128         cellSysutilCheckCallback();
     125    /* Check if exit callback was called */
     126    cellSysutilCheckCallback();
    129127#endif
    130     }
    131128}
    132129
  • trunk/src/platform/ps3/ps3app.h

    r2183 r2222  
    3131
    3232    void ShowPointer(bool show);
    33     void Run();
     33    void Tick();
    3434
    3535private:
  • trunk/src/platform/sdl/sdlapp.cpp

    r2183 r2222  
    110110}
    111111
    112 void SdlApp::Run()
     112void SdlApp::Tick()
    113113{
    114     while (!Ticker::Finished())
    115     {
    116114#if defined USE_SDL && defined USE_D3D9
    117         HRESULT hr;
    118         hr = g_d3ddevice->BeginScene();
    119         if (FAILED(hr))
    120             Abort();
     115    HRESULT hr;
     116    hr = g_d3ddevice->BeginScene();
     117    if (FAILED(hr))
     118        Abort();
    121119#endif
    122         /* Tick the renderer, show the frame and clamp to desired framerate. */
    123         Ticker::TickDraw();
     120    /* Tick the renderer, show the frame and clamp to desired framerate. */
     121    Ticker::TickDraw();
    124122#if defined USE_SDL
    125123#   if defined USE_D3D9
    126         hr = g_d3ddevice->EndScene();
    127         if (FAILED(hr))
    128             Abort();
    129         hr = g_d3ddevice->Present(NULL, NULL, NULL, NULL);
    130         if (FAILED(hr))
    131             Abort();
     124    hr = g_d3ddevice->EndScene();
     125    if (FAILED(hr))
     126        Abort();
     127    hr = g_d3ddevice->Present(NULL, NULL, NULL, NULL);
     128    if (FAILED(hr))
     129        Abort();
    132130#   else
    133         SDL_GL_SwapBuffers();
     131    SDL_GL_SwapBuffers();
    134132#   endif
    135133#endif
    136     }
    137134}
    138135
  • trunk/src/platform/sdl/sdlapp.h

    r2183 r2222  
    3131
    3232    void ShowPointer(bool show);
    33     void Run();
     33    void Tick();
    3434
    3535private:
  • trunk/src/platform/xbox/xboxapp.cpp

    r2183 r2222  
    6262}
    6363
    64 void XboxApp::Run()
     64void XboxApp::Tick()
    6565{
    66     while (!Ticker::Finished())
    67     {
    68         /* Tick the renderer, show the frame and clamp to desired framerate. */
    69         Ticker::TickDraw();
     66    /* Tick the renderer, show the frame and clamp to desired framerate. */
     67    Ticker::TickDraw();
    7068
    7169#if defined _XBOX
    72         g_d3ddevice->Present(NULL, NULL, NULL, NULL);
     70    g_d3ddevice->Present(NULL, NULL, NULL, NULL);
    7371#endif
    74     }
    7572}
    7673
  • trunk/src/platform/xbox/xboxapp.h

    r2216 r2222  
    3131
    3232    void ShowPointer(bool show);
    33     void Run();
     33    void Tick();
    3434
    3535private:
Note: See TracChangeset for help on using the changeset viewer.