commit 529f1754ff15880c8e668f02d0b7144d37fabeba
parent 326d4061b95da2fa868e7ee26a1ee9e60f039d34
Author: Matsuda Kenji <info@mtkn.jp>
Date: Thu, 22 Dec 2022 12:03:32 +0900
add preprocess
Diffstat:
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/ex2/ex2.c b/ex2/ex2.c
@@ -11,6 +11,8 @@
#define INIT_HEIGHT 600
#define FPS 60
+#define COUNT_FPS
+
/* variables */
Display *display;
@@ -64,7 +66,9 @@ main(void)
int px, py;
int quit;
long t0, t1, dt;
- int fps_count;
+#ifdef COUNT_FPS
+ int fps_count = 0;
+#endif
struct timespec ts;
XEvent event;
@@ -72,7 +76,6 @@ main(void)
quit = 0;
clock_gettime(CLOCK_MONOTONIC, &ts);
t0 = ts.tv_nsec;
- fps_count = 0;
while (!quit){
while(XPending(display) > 0){
@@ -104,6 +107,7 @@ main(void)
t1 = ts.tv_nsec;
dt = t1 > t0 ? t1 - t0 : t1 - t0 + 1000 * 1000 * 1000;
}
+#ifdef COUNT_FPS
// count fps.
// simple but not precise.
fps_count++;
@@ -111,6 +115,7 @@ main(void)
printf("fps: %u\n", fps_count);
fps_count = 0;
}
+#endif
clock_gettime(CLOCK_MONOTONIC, &ts);
t0 = ts.tv_nsec;