[waffle] [PATCH 23/33] examples/gl_basic: use native sleep functions
Emil Velikov
emil.l.velikov at gmail.com
Mon Jul 7 10:28:30 PDT 2014
nanosleep does not exist under Windows, use Sleep instead.
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
examples/gl_basic.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/examples/gl_basic.c b/examples/gl_basic.c
index 8e1a28c..28af1ca 100644
--- a/examples/gl_basic.c
+++ b/examples/gl_basic.c
@@ -43,7 +43,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#if !defined(_WIN32)
#include <time.h>
+#else
+#include <windows.h>
+#endif
#ifdef __APPLE__
# import <Foundation/NSAutoreleasePool.h>
@@ -370,11 +374,13 @@ draw(struct waffle_window *window, bool resize)
int width = WINDOW_WIDTH;
int height = WINDOW_HEIGHT;
+#if !defined(_WIN32)
static const struct timespec sleep_time = {
// 0.5 sec
.tv_sec = 0,
.tv_nsec = 500000000,
};
+#endif
for (int i = 0; i < 3; ++i) {
switch (i) {
@@ -419,7 +425,11 @@ draw(struct waffle_window *window, bool resize)
if (!ok)
return false;
+#if !defined(_WIN32)
nanosleep(&sleep_time, NULL);
+#else
+ Sleep(500);
+#endif
}
return true;
--
2.0.0
More information about the waffle
mailing list