comparison render_sdl.c @ 272:9b04b57434b5

Implement LDI
author Mike Pavone <pavone@retrodev.com>
date Thu, 02 May 2013 22:26:47 -0700
parents 7ccc4ae86e07
children 8e2fa485c0f2
comparison
equal deleted inserted replaced
271:969ee17471c5 272:9b04b57434b5
364 puts(""); 364 puts("");
365 exit(0); 365 exit(0);
366 } 366 }
367 } 367 }
368 //TODO: Adjust frame delay so we actually get 60 FPS rather than 62.5 FPS 368 //TODO: Adjust frame delay so we actually get 60 FPS rather than 62.5 FPS
369 uint32_t current = SDL_GetTicks(); 369 /*uint32_t current = SDL_GetTicks();
370 uint32_t desired = last_frame + FRAME_DELAY; 370 uint32_t desired = last_frame + FRAME_DELAY;
371 if (current < desired) { 371 if (current < desired) {
372 uint32_t delay = last_frame + FRAME_DELAY - current; 372 uint32_t delay = last_frame + FRAME_DELAY - current;
373 //TODO: Calculate MIN_DELAY at runtime 373 //TODO: Calculate MIN_DELAY at runtime
374 if (delay > MIN_DELAY) { 374 if (delay > MIN_DELAY) {
375 SDL_Delay((delay/MIN_DELAY)*MIN_DELAY); 375 SDL_Delay((delay/MIN_DELAY)*MIN_DELAY);
376 } 376 }
377 while ((desired) >= SDL_GetTicks()) { 377 while ((desired) >= SDL_GetTicks()) {
378 } 378 }
379 } 379 }*/
380 render_context(context); 380 render_context(context);
381 381
382 /* 382
383 //TODO: Figure out why this causes segfaults 383 //TODO: Figure out why this causes segfaults
384 frame_counter++; 384 /*frame_counter++;
385 if ((last_frame - start) > 1000) { 385 if ((last_frame - start) > 1000) {
386 if (start) { 386 if (start && (last_frame-start)) {
387 printf("\r%f fps", ((float)frame_counter) / (((float)(last_frame-start)) / 1000.0)); 387 printf("\r%f fps", ((float)frame_counter) / (((float)(last_frame-start)) / 1000.0));
388 fflush(stdout); 388 fflush(stdout);
389 } 389 }
390 start = last_frame; 390 start = last_frame;
391 frame_counter = 0; 391 frame_counter = 0;