# HG changeset patch # User John Tsiombikas # Date 1315381751 -10800 # Node ID 75a63f9ab7cc6f82a9c25eea32c332a715d1aca1 # Parent 21d58290e634d50cb86262f5ad3b6c3edd78231f ha! diff -r 21d58290e634 -r 75a63f9ab7cc src/istereo.c --- a/src/istereo.c Wed Sep 07 10:15:35 2011 +0300 +++ b/src/istereo.c Wed Sep 07 10:49:11 2011 +0300 @@ -21,13 +21,16 @@ unsigned int prog; unsigned int tex; -int stereo; +int view_xsz, view_ysz; + +int stereo = 1; /* construction parameters */ int sides = 24; int segm = 20; float ring_height = 0.5; +float split = 0.5; int init(void) { @@ -44,6 +47,8 @@ return -1; } + cam_fov(30.0); + return 0; } @@ -57,39 +62,47 @@ float pan_x, pan_y, z; float tsec = get_sec(); - z = ring_height * (segm - 1); + z = ring_height * segm; worm(tsec, z, &pan_x, &pan_y); + glClear(GL_COLOR_BUFFER_BIT); + if(stereo) { -#if 0 + int split_pt = (int)((float)view_ysz * split); + /* left eye */ - glDrawBuffer(GL_BACK_LEFT); + glViewport(0, 0, view_xsz, split_pt); + cam_aspect((float)split_pt / (float)view_xsz); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); + gl_matrix_mode(GL_PROJECTION); + gl_load_identity(); cam_stereo_proj_matrix(CAM_LEFT); + gl_rotatef(-90, 0, 0, 1); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); + gl_matrix_mode(GL_MODELVIEW); + gl_load_identity(); cam_stereo_view_matrix(CAM_LEFT); - glTranslatef(-pan_x, -pan_y, -1.1 * ring_height * segm); + gl_translatef(-pan_x, -pan_y, -1.1 * ring_height * segm); + /*gl_rotatef(-90, 0, 0, 1);*/ render(tsec); /* right eye */ - glDrawBuffer(GL_BACK_RIGHT); + glViewport(0, split_pt, view_xsz, view_ysz - split_pt); + cam_aspect((float)(view_ysz - split_pt) / (float)view_xsz); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); + gl_matrix_mode(GL_PROJECTION); + gl_load_identity(); cam_stereo_proj_matrix(CAM_RIGHT); + gl_rotatef(-90, 0, 0, 1); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); + gl_matrix_mode(GL_MODELVIEW); + gl_load_identity(); cam_stereo_view_matrix(CAM_RIGHT); - glTranslatef(-pan_x, -pan_y, -1.1 * ring_height * segm); + gl_translatef(-pan_x, -pan_y, -1.1 * ring_height * segm); + /*gl_rotatef(-90, 0, 0, 1);*/ render(tsec); -#endif } else { gl_matrix_mode(GL_MODELVIEW); gl_load_identity(); @@ -135,8 +148,6 @@ static void render(float t) { - glClear(GL_COLOR_BUFFER_BIT); - draw_tunnel(t); } @@ -188,6 +199,14 @@ } gl_end(); + /*gl_begin(GL_QUADS); + gl_color3f(1.0, 0.3, 0.2); + gl_vertex2f(-100, -100); + gl_vertex2f(100, -100); + gl_vertex2f(100, 0); + gl_vertex2f(-100, 0); + gl_end();*/ + bind_texture(0, 0); } @@ -247,7 +266,10 @@ gl_matrix_mode(GL_PROJECTION); gl_load_identity(); - glu_perspective(45.0, (float)x / (float)y, 1.0, 1000.0); + glu_perspective(40.0, (float)x / (float)y, 0.5, 500.0); + + view_xsz = x; + view_ysz = y; } static unsigned int get_shader_program(const char *vfile, const char *pfile) diff -r 21d58290e634 -r 75a63f9ab7cc src/sanegl.c --- a/src/sanegl.c Wed Sep 07 10:15:35 2011 +0300 +++ b/src/sanegl.c Wed Sep 07 10:49:11 2011 +0300 @@ -216,7 +216,8 @@ void glu_perspective(float vfov, float aspect, float near, float far) { - float x = near * tan(vfov / 2.0); + float vfov_rad = M_PI * vfov / 180.0; + float x = near * tan(vfov_rad / 2.0); gl_frustum(-aspect * x, aspect * x, -x, x, near, far); }