MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / loop

Function loop

deps/SDL2/test/testsprite2.c:246–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244}
245
246void
247loop()
248{
249 Uint32 now;
250 int i;
251 SDL_Event event;
252
253 /* Check for events */
254 while (SDL_PollEvent(&event)) {
255 SDLTest_CommonEvent(state, &event, &done);
256 }
257 for (i = 0; i < state->num_windows; ++i) {
258 if (state->windows[i] == NULL)
259 continue;
260 MoveSprites(state->renderers[i], sprites[i]);
261 }
262#ifdef __EMSCRIPTEN__
263 if (done) {
264 emscripten_cancel_main_loop();
265 }
266#endif
267
268 frames++;
269 now = SDL_GetTicks();
270 if (SDL_TICKS_PASSED(now, next_fps_check)) {
271 /* Print out some timing information */
272 const Uint32 then = next_fps_check - fps_check_delay;
273 const double fps = ((double) frames * 1000) / (now - then);
274 SDL_Log("%2.2f frames per second\n", fps);
275 next_fps_check = now + fps_check_delay;
276 frames = 0;
277 }
278
279}
280
281int
282main(int argc, char *argv[])

Callers 1

mainFunction · 0.70

Calls 5

SDL_PollEventFunction · 0.85
SDLTest_CommonEventFunction · 0.85
SDL_LogFunction · 0.85
MoveSpritesFunction · 0.70
SDL_GetTicksFunction · 0.50

Tested by

no test coverage detected