part system
[demo_prior] / src / part.h
diff --git a/src/part.h b/src/part.h
new file mode 100644 (file)
index 0000000..8d0fbdf
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef PART_H_
+#define PART_H_
+
+struct demo_part {
+       const char *name;
+       long start_time;
+       long in_time;   /* transition overlap with previous part */
+
+       int (*init)(void);
+       void (*destroy)(void);
+
+       void (*start)(void);
+       void (*stop)(void);
+
+       /* tm is the time from the start of this part in milliseconds */
+       void (*draw)(long tm);
+
+       /* optional: transition draw functions. if null, the regular draw will be
+        * called for the duration of the transition instead
+        */
+       void (*draw_in)(long tm, float t);
+       void (*draw_out)(long tm, float t);
+
+       /* optional, will be called only when active */
+       void (*reshape)(int x, int y);
+       void (*keyboard)(int key, int st);
+       void (*mbutton)(int bn, int st, int x, int y);
+       void (*mmotion)(int x, int y);
+};
+
+#define MAX_DEMO_PARTS 64
+extern struct demo_part *parts[MAX_DEMO_PARTS];
+extern int num_parts;
+
+extern struct demo_part *cur_part, *prev_part;
+
+void add_part(struct demo_part *part);
+void switch_part(struct demo_part *part);
+
+struct demo_part *find_part(const char *name);
+
+#endif /* PART_H_ */