diff --git a/src/lua_externs.h b/src/lua_externs.h index ec2f3d8f14f3dad7cec6823082ed5a5edc54dcd1..f202fe916a2f040b65c772ae86f03346103d4e98 100644 --- a/src/lua_externs.h +++ b/src/lua_externs.h @@ -20,3 +20,4 @@ int luaopen_wait(lua_State *L); void create_particles_thread(); void thread_particle_new_keyframes(int nb_keyframes); bool draw_waiting(lua_State *L); +bool is_waiting(); diff --git a/src/main.c b/src/main.c index 90bea50c8903abfa9c8c98b0f474997467d72edc..bce654aa287d81e5187fc2e9032f57ceab7309c8 100644 --- a/src/main.c +++ b/src/main.c @@ -458,7 +458,7 @@ void on_redraw() /* Gather our frames per second */ Frames++; - { + if (!is_waiting()) { int t = SDL_GetTicks(); if (t - T0 >= 1000) { float seconds = (t - T0) / 1000.0; @@ -472,6 +472,14 @@ void on_redraw() count_keyframes = 0; } } + else + { + T0 = SDL_GetTicks(); + Frames = 0; + last_keyframe = 0; + nb_keyframes = 0; + count_keyframes = 0; + } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); diff --git a/src/wait.c b/src/wait.c index 6cd238a4d8a8ec407bb2667fdd36dccd2840c992..5c687d4a5f16c5e6b71f9b753e6385b4bae469d8 100644 --- a/src/wait.c +++ b/src/wait.c @@ -35,6 +35,7 @@ extern SDL_Surface *screen; static bool wait_hooked = FALSE; static int waiting = 0; static int waited_count = 0; +static long waited_ticks = 0; static int bkg_realw, bkg_realh, bkg_w, bkg_h; static GLuint bkg_t = 0; static int wait_draw_ref = LUA_NOREF; @@ -81,6 +82,12 @@ bool draw_waiting(lua_State *L) return TRUE; } +bool is_waiting() +{ + if (!waiting) return FALSE; + return TRUE; +} + extern void on_redraw(); static void hook_wait_display(lua_State *L, lua_Debug *ar) { @@ -89,6 +96,7 @@ static void hook_wait_display(lua_State *L, lua_Debug *ar) on_redraw(); } +extern long draw_tick_skip; static int enable(lua_State *L) { waiting++; @@ -96,6 +104,9 @@ static int enable(lua_State *L) // Grab currently displayed stuff if (waiting == 1) { + waited_count = 0; + waited_ticks = SDL_GetTicks(); + int w, h; SDL_GetWindowSize(window, &w, &h); @@ -117,8 +128,6 @@ static int enable(lua_State *L) glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, w, h); printf("Make wait background texture %d : %dx%d (%d, %d)\n", bkg_t, w, h, bkg_realw, bkg_realh); - waited_count = 0; - int count = 300; if (lua_isnumber(L, 1)) count = lua_tonumber(L, 1); if (!lua_gethookmask(L)) @@ -155,7 +164,8 @@ static int disable(lua_State *L) } if (wait_hooked) lua_sethook(L, NULL, 0, 0); if (wait_draw_ref != LUA_NOREF) luaL_unref(L, LUA_REGISTRYINDEX, wait_draw_ref); - printf("Wait finished, counted %d\n", waited_count); + waited_ticks = SDL_GetTicks() - waited_ticks; + printf("Wait finished, counted %d, %ld ticks\n", waited_count, waited_ticks); } lua_pushboolean(L, waiting > 0); lua_pushnumber(L, waiting);