aboutsummaryrefslogtreecommitdiffstats
path: root/donut.c
diff options
context:
space:
mode:
Diffstat (limited to 'donut.c')
-rw-r--r--donut.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/donut.c b/donut.c
index 250d0ce..b136c36 100644
--- a/donut.c
+++ b/donut.c
@@ -23,13 +23,15 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
-#define __USE_MISC
#include <math.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
+char *argv0;
+#include "arg.h"
+
#define BETWEEN(x, min, max) min < x && x< max
const float theta_spacing = 0.07;
@@ -80,7 +82,32 @@ void drawTorus (float *b, const float *Az, const float *Bz) {
free(z);
}
-int main() {
+void usage() {
+ fprintf(stderr, "usage: %s [-h] [-s scale] [-r speed]\n", argv0);
+ exit(1);
+}
+
+int main(int argc, char **argv) {
+ /*#define SCALE 2
+ #define ROTATION_SPEED_FACTOR 1*/
+
+ int SCALE = 2;
+ int ROTATION_SPEED_FACTOR = 1;
+
+ ARGBEGIN {
+ case 's':
+ SCALE = atoi(EARGF(usage()));
+ break;
+ case 'r':
+ ROTATION_SPEED_FACTOR = atoi(EARGF(usage()));
+ break;
+ case 'h':
+ usage();
+ break;
+ default:
+ break;
+ } ARGEND
+
Display *dis = XOpenDisplay((char*)0);
int screen = DefaultScreen(dis);
unsigned long black = BlackPixel(dis, screen), white = WhitePixel(dis, screen);
@@ -137,8 +164,7 @@ int main() {
A += (rtime-stime) * (0.04f * ROTATION_SPEED_FACTOR) / (1000/FPS_MAX);// / (1000/FPS_MAX), 0.04f * ROTATION_SPEED_FACTOR);
B += (rtime-stime) * (0.02f * ROTATION_SPEED_FACTOR) / (1000/FPS_MAX);// / (1000/FPS_MAX), 0.04f * ROTATION_SPEED_FACTOR);
- printf("%.1f %d ", (rtime-stime), 1000/(FPS_MAX));
- printf("fps: %.1f %d \r", 1000/(rtime-stime), FPS_MAX);
+ printf("fps: %.1f \r", 1000/(rtime-stime));
}
}