istereo
changeset 18:6851489e70c2
timing?
author | John Tsiombikas <nuclear@mutantstargoat.com> |
---|---|
date | Wed, 07 Sep 2011 09:53:01 +0300 |
parents | 4c20f10a7183 |
children | ab4972098eb7 |
files | src/istereo.c |
diffstat | 1 files changed, 39 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- a/src/istereo.c Wed Sep 07 09:35:20 2011 +0300 1.2 +++ b/src/istereo.c Wed Sep 07 09:53:01 2011 +0300 1.3 @@ -1,4 +1,5 @@ 1.4 #include <stdio.h> 1.5 +#include <math.h> 1.6 #include <assert.h> 1.7 #include <unistd.h> 1.8 #include "opengl.h" 1.9 @@ -7,12 +8,22 @@ 1.10 #include "sdr.h" 1.11 #include "respath.h" 1.12 #include "tex.h" 1.13 +#include "config.h" 1.14 1.15 static unsigned int get_shader_program(const char *vfile, const char *pfile); 1.16 +static float get_sec(void); 1.17 1.18 unsigned int prog; 1.19 unsigned int tex; 1.20 1.21 +int stereo; 1.22 + 1.23 +/* construction parameters */ 1.24 +int sides = 24; 1.25 +int segm = 20; 1.26 +float ring_height = 0.5; 1.27 + 1.28 + 1.29 int init(void) 1.30 { 1.31 add_resource_path("sdr"); 1.32 @@ -38,6 +49,8 @@ 1.33 1.34 void redraw(void) 1.35 { 1.36 + float t = get_sec(); 1.37 + 1.38 glClearColor(0.4, 0.6, 1.0, 1.0); 1.39 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 1.40 1.41 @@ -46,6 +59,7 @@ 1.42 gl_matrix_mode(GL_MODELVIEW); 1.43 gl_load_identity(); 1.44 gl_translatef(0, 0, -8); 1.45 + gl_rotatef(t * 100.0, 0, 0, 1); 1.46 1.47 bind_texture(tex, 0); 1.48 set_uniform_int(prog, "tex", 0); 1.49 @@ -95,3 +109,28 @@ 1.50 } 1.51 return prog; 1.52 } 1.53 + 1.54 + 1.55 +#ifdef IPHONE 1.56 +#include <QuartzCore/QuartzCore.h> 1.57 + 1.58 +static float get_sec(void) 1.59 +{ 1.60 + static float first; 1.61 + static int init; 1.62 + 1.63 + if(!init) { 1.64 + init = 1; 1.65 + first = CACurrentMediaTime(); 1.66 + return 0.0f; 1.67 + } 1.68 + return CACurrentMediaTime() - first; 1.69 +} 1.70 + 1.71 +#else 1.72 + 1.73 +static float get_sec(void) 1.74 +{ 1.75 + return (float)glutGet(GLUT_ELAPSED_TIME) / 1000.0f; 1.76 +} 1.77 +#endif