istereo2
diff src/istereo.c @ 4:d4fed8aac9a6
fixed all sideways crap in the effect code
fixed fov on all orientations
fixed inverted tangent vector in bump mapped version
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 21 Sep 2015 21:12:36 +0300 |
parents | 81d35769f546 |
children | 3bccfc7d10fe |
line diff
1.1 --- a/src/istereo.c Mon Sep 21 07:40:34 2015 +0300 1.2 +++ b/src/istereo.c Mon Sep 21 21:12:36 2015 +0300 1.3 @@ -118,16 +118,16 @@ 1.4 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 1.5 1.6 if(stereo) { 1.7 - int split_pt = (int)((float)view_ysz * split); 1.8 + int split_pt = (int)((float)view_xsz * split); 1.9 1.10 /* right eye */ 1.11 - glViewport(0, 0, view_xsz, split_pt); 1.12 - cam_aspect((float)split_pt / (float)view_xsz); 1.13 + glViewport(0, 0, split_pt, view_ysz); 1.14 + cam_aspect((float)split_pt / (float)view_ysz); 1.15 1.16 gl_matrix_mode(GL_PROJECTION); 1.17 gl_load_identity(); 1.18 cam_stereo_proj_matrix(CAM_RIGHT); 1.19 - gl_rotatef(-90, 0, 0, 1); 1.20 + //gl_rotatef(-90, 0, 0, 1); 1.21 1.22 gl_matrix_mode(GL_MODELVIEW); 1.23 gl_load_identity(); 1.24 @@ -137,13 +137,13 @@ 1.25 render(tsec); 1.26 1.27 /* left eye */ 1.28 - glViewport(0, split_pt, view_xsz, view_ysz - split_pt); 1.29 - cam_aspect((float)(view_ysz - split_pt) / (float)view_xsz); 1.30 + glViewport(split_pt, 0, view_xsz - split_pt, view_ysz); 1.31 + cam_aspect((float)(view_xsz - split_pt) / (float)view_ysz); 1.32 1.33 gl_matrix_mode(GL_PROJECTION); 1.34 gl_load_identity(); 1.35 cam_stereo_proj_matrix(CAM_LEFT); 1.36 - gl_rotatef(-90, 0, 0, 1); 1.37 + //gl_rotatef(-90, 0, 0, 1); 1.38 1.39 gl_matrix_mode(GL_MODELVIEW); 1.40 gl_load_identity(); 1.41 @@ -157,7 +157,7 @@ 1.42 1.43 gl_matrix_mode(GL_PROJECTION); 1.44 gl_load_identity(); 1.45 - gl_rotatef(-90, 0, 0, 1); 1.46 + //gl_rotatef(-90, 0, 0, 1); 1.47 cam_proj_matrix(); 1.48 1.49 gl_matrix_mode(GL_MODELVIEW); 1.50 @@ -280,7 +280,7 @@ 1.51 dfdv = v3_sub(pos_dv, pos); 1.52 norm = v3_cross(dfdv, dfdu); 1.53 1.54 - gl_vertex_attrib3f(tang_loc, dfdu.x, dfdu.y, dfdu.z); 1.55 + gl_vertex_attrib3f(tang_loc, dfdu.x, -dfdu.y, dfdu.z); 1.56 gl_normal3f(norm.x, norm.y, norm.z); 1.57 gl_texcoord2f(u * 2.0, v * 4.0); 1.58 gl_vertex3f(pos.x, pos.y, pos.z); 1.59 @@ -348,9 +348,15 @@ 1.60 { 1.61 glViewport(0, 0, x, y); 1.62 1.63 + float aspect = (float)x / (float)y; 1.64 + float maxfov = 40.0; 1.65 + float vfov = aspect > 1.0 ? maxfov / aspect : maxfov; 1.66 + 1.67 + cam_fov(vfov); 1.68 + 1.69 gl_matrix_mode(GL_PROJECTION); 1.70 gl_load_identity(); 1.71 - glu_perspective(40.0, (float)x / (float)y, 0.5, 500.0); 1.72 + glu_perspective(vfov, aspect, 0.5, 500.0); 1.73 1.74 view_xsz = x; 1.75 view_ysz = y;