better timers
This commit is contained in:
parent
1567cf0d15
commit
f182582d7b
15
maze.c
15
maze.c
@ -13,7 +13,7 @@
|
|||||||
// Performance options
|
// Performance options
|
||||||
#define DOLIGHTING
|
#define DOLIGHTING
|
||||||
// #define FASTTRIS
|
// #define FASTTRIS
|
||||||
#define DITHERSTART 1
|
#define DITHERSTART -1
|
||||||
#define DITHEREND 8
|
#define DITHEREND 8
|
||||||
#define TARGETFPS 60
|
#define TARGETFPS 60
|
||||||
#define SECPERFRAME 1.0 / TARGETFPS
|
#define SECPERFRAME 1.0 / TARGETFPS
|
||||||
@ -49,8 +49,9 @@ int main() { // int argc, char **argv) {
|
|||||||
#endif
|
#endif
|
||||||
eprintf("Initialized renderer\n");
|
eprintf("Initialized renderer\n");
|
||||||
|
|
||||||
haloo3d_easytimer frametimer;
|
haloo3d_easytimer frametimer, sdltimer;
|
||||||
haloo3d_easytimer_init(&frametimer, AVGWEIGHT);
|
haloo3d_easytimer_init(&frametimer, AVGWEIGHT);
|
||||||
|
haloo3d_easytimer_init(&sdltimer, AVGWEIGHT);
|
||||||
|
|
||||||
// Load the junk + generate stuff
|
// Load the junk + generate stuff
|
||||||
haloo3d_obj *flooro = haloo3d_easystore_addobj(&storage, "floor");
|
haloo3d_obj *flooro = haloo3d_easystore_addobj(&storage, "floor");
|
||||||
@ -130,15 +131,21 @@ int main() { // int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
haloo3d_print(&render.tprint,
|
haloo3d_print(&render.tprint,
|
||||||
"Last frame: %05.2f (%05.2f)\nTris: %d / %d\nVerts: %d\n",
|
"Last frame: %05.2f (%05.2f)\nLast SDLFl: %05.2f "
|
||||||
frametimer.last * 1000, frametimer.sum * 1000, totaldrawn,
|
"(%05.2f)\nTris: %d / %d\nVerts: %d\n",
|
||||||
|
frametimer.last * 1000, frametimer.sum * 1000,
|
||||||
|
sdltimer.last * 1000, sdltimer.sum * 1000, totaldrawn,
|
||||||
render.totalfaces, render.totalverts);
|
render.totalfaces, render.totalverts);
|
||||||
|
|
||||||
unigi_graphics_blit(0, (unigi_type_color *)render.window.buffer,
|
unigi_graphics_blit(0, (unigi_type_color *)render.window.buffer,
|
||||||
res.width * res.height);
|
res.width * res.height);
|
||||||
|
|
||||||
|
haloo3d_easytimer_start(&sdltimer);
|
||||||
unigi_graphics_flush();
|
unigi_graphics_flush();
|
||||||
|
haloo3d_easytimer_end(&sdltimer);
|
||||||
|
|
||||||
haloo3d_easytimer_end(&frametimer);
|
haloo3d_easytimer_end(&frametimer);
|
||||||
|
|
||||||
float waittime = SECPERFRAME - frametimer.last;
|
float waittime = SECPERFRAME - frametimer.last;
|
||||||
if (waittime > 0) {
|
if (waittime > 0) {
|
||||||
unigi_time_sleep(waittime * unigi_time_clocks_per_s);
|
unigi_time_sleep(waittime * unigi_time_clocks_per_s);
|
||||||
|
Loading…
Reference in New Issue
Block a user