# HG changeset patch # User John Tsiombikas # Date 1315379719 -10800 # Node ID ab4972098eb72a34c3fbfce551f75ee0975889ef # Parent 6851489e70c2543358606f578a578099542eb688 tunnel first take diff -r 6851489e70c2 -r ab4972098eb7 src/istereo.c --- a/src/istereo.c Wed Sep 07 09:53:01 2011 +0300 +++ b/src/istereo.c Wed Sep 07 10:15:19 2011 +0300 @@ -8,8 +8,13 @@ #include "sdr.h" #include "respath.h" #include "tex.h" +#include "cam.h" #include "config.h" +static void render(float t); +static void draw_tunnel(float t); +static void tunnel_vertex(float u, float v, float du, float dv, float t); +static void worm(float t, float z, float *tx, float *ty); static unsigned int get_shader_program(const char *vfile, const char *pfile); static float get_sec(void); @@ -49,9 +54,53 @@ void redraw(void) { - float t = get_sec(); + float pan_x, pan_y, z; + float tsec = get_sec(); - glClearColor(0.4, 0.6, 1.0, 1.0); + z = ring_height * (segm - 1); + worm(tsec, z, &pan_x, &pan_y); + + if(stereo) { +#if 0 + /* left eye */ + glDrawBuffer(GL_BACK_LEFT); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + cam_stereo_proj_matrix(CAM_LEFT); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + cam_stereo_view_matrix(CAM_LEFT); + glTranslatef(-pan_x, -pan_y, -1.1 * ring_height * segm); + + render(tsec); + + /* right eye */ + glDrawBuffer(GL_BACK_RIGHT); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + cam_stereo_proj_matrix(CAM_RIGHT); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + cam_stereo_view_matrix(CAM_RIGHT); + glTranslatef(-pan_x, -pan_y, -1.1 * ring_height * segm); + + render(tsec); +#endif + } else { + gl_matrix_mode(GL_MODELVIEW); + gl_load_identity(); + cam_view_matrix(); + gl_translatef(-pan_x, -pan_y, -1.1 * ring_height * segm); + + render(tsec); + } + + + /*glClearColor(0.4, 0.6, 1.0, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); bind_program(prog); @@ -79,11 +128,119 @@ gl_vertex3f(-1, 1, 0); gl_end(); - bind_texture(0, 0); + bind_texture(0, 0);*/ assert(glGetError() == GL_NO_ERROR); } +static void render(float t) +{ + glClear(GL_COLOR_BUFFER_BIT); + + draw_tunnel(t); +} + +static void draw_tunnel(float t) +{ + static const float uoffs[] = {0.0, 0.0, 1.0, 1.0}; + static const float voffs[] = {0.0, 1.0, 1.0, 0.0}; + int i, j, k; + float du, dv; + + bind_program(prog); + set_uniform_float(prog, "t", t); + + bind_texture(tex, 0); + + /*glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + //glTranslatef(0, -t * 1.5, 0); + glTranslatef(0, -t * 0.5, 0);*/ + + gl_begin(GL_QUADS); + gl_color3f(1.0, 1.0, 1.0); + + du = 1.0 / sides; + dv = 1.0 / segm; + + for(i=0; i