dsys2

diff src/dsys2.h @ 0:34d90cd9ef9b

starting a new demosystem
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 20 Aug 2011 07:48:16 +0300
parents
children 94ce16dd20c0
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/dsys2.h	Sat Aug 20 07:48:16 2011 +0300
     1.3 @@ -0,0 +1,62 @@
     1.4 +#ifndef DSYS2_H_
     1.5 +#define DSYS2_H_
     1.6 +
     1.7 +#include <stdio.h>
     1.8 +
     1.9 +struct dsys_demo;
    1.10 +struct dsys_event;
    1.11 +
    1.12 +typedef float demotime_t;
    1.13 +
    1.14 +enum dsys_evtype {
    1.15 +	DSYS_SINGLE,
    1.16 +	DSYS_PERIODIC
    1.17 +};
    1.18 +
    1.19 +
    1.20 +struct dsys_demo *dsys_open(const char *fname);
    1.21 +struct dsys_demo *dsys_open_stream(FILE *fp);
    1.22 +void dsys_close(struct dsys_demo *demo);
    1.23 +
    1.24 +void dsys_update(struct dsys_demo *demo, demotime_t tm);
    1.25 +
    1.26 +
    1.27 +void dsys_start(struct dsys_demo *demo);
    1.28 +void dsys_stop(struct dsys_demo *demo);
    1.29 +int dsys_is_running(struct dsys_demo *demo);
    1.30 +
    1.31 +
    1.32 +demotime_t dsys_duration(struct dsys_demo *demo);
    1.33 +demotime_t dsys_time(struct dsys_demo *demo);
    1.34 +float dsys_progress(struct dsys_demo *demo);
    1.35 +
    1.36 +/* seek without continuity */
    1.37 +void dsys_seek(struct dsys_demo *demo, demotime_t tm);
    1.38 +void dsys_seek_norm(struct dsys_demo *demo, float t);
    1.39 +
    1.40 +/* seek by accelerating time */
    1.41 +void dsys_warp(struct dsys_demo *demo, demotime_t tm);
    1.42 +void dsys_warp_norm(struct dsys_demo *demo, float t);
    1.43 +
    1.44 +
    1.45 +/* events */
    1.46 +struct dsys_event *dsys_event(struct dsys_demo *demo, const char *name);
    1.47 +
    1.48 +enum dsys_evtype dsys_event_type(struct dsys_event *ev);
    1.49 +float dsys_event_value(struct dsys_event *ev);
    1.50 +
    1.51 +void dsys_event_callback(struct dsys_event *ev, void (*func)(void*), void *cls);
    1.52 +void dsys_event_link(struct dsys_event *ev, float *link);
    1.53 +
    1.54 +
    1.55 +/* time conversion */
    1.56 +demotime_t dsys_sec_to_dtime(float sec);
    1.57 +demotime_t dsys_msec_to_dtime(unsigned long msec);
    1.58 +demotime_t dsys_norm_to_dtime(float t);
    1.59 +
    1.60 +float dsys_dtime_to_sec(demotime_t tm);
    1.61 +unsigned long dsys_dtime_to_msec(demotime_t tm);
    1.62 +float dsys_dtime_to_norm(demotime_t tm);
    1.63 +
    1.64 +
    1.65 +#endif	/* DSYS2_H_ */