istereo2

diff src/istereo.c @ 20:2b85d05df3f2

animation controls for easier screenshot grabbing
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 02 Oct 2015 04:54:55 +0300
parents 25d821ab1ca2
children c6971ff4795e
line diff
     1.1 --- a/src/istereo.c	Fri Oct 02 04:20:21 2015 +0300
     1.2 +++ b/src/istereo.c	Fri Oct 02 04:54:55 2015 +0300
     1.3 @@ -51,6 +51,9 @@
     1.4  int view_xsz, view_ysz;
     1.5  float view_aspect;
     1.6  
     1.7 +static int paused;
     1.8 +static long sys_msec, time_offset, time_msec, last_pause;
     1.9 +
    1.10  int stereo = 0;
    1.11  int use_bump = 0;
    1.12  int show_opt = 1;
    1.13 @@ -138,7 +141,9 @@
    1.14  void redraw(void)
    1.15  {
    1.16  	float pan_x, pan_y, z;
    1.17 -	float tsec = get_time_sec();
    1.18 +	sys_msec = get_time_msec();
    1.19 +	time_msec = (paused ? last_pause : sys_msec) + time_offset;
    1.20 +	double tsec = time_msec / 1000.0;
    1.21  
    1.22  	z = ring_height * segm;
    1.23  	worm(tsec, z, &pan_x, &pan_y);
    1.24 @@ -433,6 +438,21 @@
    1.25  	}
    1.26  }
    1.27  
    1.28 +void playpause(void)
    1.29 +{
    1.30 +	paused = !paused;
    1.31 +	if(paused) {
    1.32 +		last_pause = sys_msec;
    1.33 +	} else {
    1.34 +		time_offset -= sys_msec - last_pause;
    1.35 +	}
    1.36 +}
    1.37 +
    1.38 +void seektime(long msec)
    1.39 +{
    1.40 +	time_offset -= msec;
    1.41 +}
    1.42 +
    1.43  static unsigned int get_shader_program(const char *vfile, const char *pfile)
    1.44  {
    1.45  	unsigned int prog, vs, ps;