istereo2
changeset 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 | dc735bdeeb8a |
children | 6a39b8912752 |
files | src/ios/viewctl.m src/istereo.c |
diffstat | 2 files changed, 27 insertions(+), 10 deletions(-) [+] |
line diff
1.1 --- a/src/ios/viewctl.m Mon Sep 21 07:40:34 2015 +0300 1.2 +++ b/src/ios/viewctl.m Mon Sep 21 21:12:36 2015 +0300 1.3 @@ -81,6 +81,17 @@ 1.4 return YES; 1.5 } 1.6 1.7 +- (BOOL)shouldAutorotate 1.8 +{ 1.9 + return YES; 1.10 +} 1.11 + 1.12 +- (UIInterfaceOrientationMask)supportedInterfaceOrientations 1.13 +{ 1.14 + return UIInterfaceOrientationMaskLandscape; 1.15 + //return UIInterfaceOrientationMaskAll; 1.16 +} 1.17 + 1.18 - (void)create_ad 1.19 { 1.20 ad = [[ADBannerView alloc] initWithAdType: ADAdTypeBanner];
2.1 --- a/src/istereo.c Mon Sep 21 07:40:34 2015 +0300 2.2 +++ b/src/istereo.c Mon Sep 21 21:12:36 2015 +0300 2.3 @@ -118,16 +118,16 @@ 2.4 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 2.5 2.6 if(stereo) { 2.7 - int split_pt = (int)((float)view_ysz * split); 2.8 + int split_pt = (int)((float)view_xsz * split); 2.9 2.10 /* right eye */ 2.11 - glViewport(0, 0, view_xsz, split_pt); 2.12 - cam_aspect((float)split_pt / (float)view_xsz); 2.13 + glViewport(0, 0, split_pt, view_ysz); 2.14 + cam_aspect((float)split_pt / (float)view_ysz); 2.15 2.16 gl_matrix_mode(GL_PROJECTION); 2.17 gl_load_identity(); 2.18 cam_stereo_proj_matrix(CAM_RIGHT); 2.19 - gl_rotatef(-90, 0, 0, 1); 2.20 + //gl_rotatef(-90, 0, 0, 1); 2.21 2.22 gl_matrix_mode(GL_MODELVIEW); 2.23 gl_load_identity(); 2.24 @@ -137,13 +137,13 @@ 2.25 render(tsec); 2.26 2.27 /* left eye */ 2.28 - glViewport(0, split_pt, view_xsz, view_ysz - split_pt); 2.29 - cam_aspect((float)(view_ysz - split_pt) / (float)view_xsz); 2.30 + glViewport(split_pt, 0, view_xsz - split_pt, view_ysz); 2.31 + cam_aspect((float)(view_xsz - split_pt) / (float)view_ysz); 2.32 2.33 gl_matrix_mode(GL_PROJECTION); 2.34 gl_load_identity(); 2.35 cam_stereo_proj_matrix(CAM_LEFT); 2.36 - gl_rotatef(-90, 0, 0, 1); 2.37 + //gl_rotatef(-90, 0, 0, 1); 2.38 2.39 gl_matrix_mode(GL_MODELVIEW); 2.40 gl_load_identity(); 2.41 @@ -157,7 +157,7 @@ 2.42 2.43 gl_matrix_mode(GL_PROJECTION); 2.44 gl_load_identity(); 2.45 - gl_rotatef(-90, 0, 0, 1); 2.46 + //gl_rotatef(-90, 0, 0, 1); 2.47 cam_proj_matrix(); 2.48 2.49 gl_matrix_mode(GL_MODELVIEW); 2.50 @@ -280,7 +280,7 @@ 2.51 dfdv = v3_sub(pos_dv, pos); 2.52 norm = v3_cross(dfdv, dfdu); 2.53 2.54 - gl_vertex_attrib3f(tang_loc, dfdu.x, dfdu.y, dfdu.z); 2.55 + gl_vertex_attrib3f(tang_loc, dfdu.x, -dfdu.y, dfdu.z); 2.56 gl_normal3f(norm.x, norm.y, norm.z); 2.57 gl_texcoord2f(u * 2.0, v * 4.0); 2.58 gl_vertex3f(pos.x, pos.y, pos.z); 2.59 @@ -348,9 +348,15 @@ 2.60 { 2.61 glViewport(0, 0, x, y); 2.62 2.63 + float aspect = (float)x / (float)y; 2.64 + float maxfov = 40.0; 2.65 + float vfov = aspect > 1.0 ? maxfov / aspect : maxfov; 2.66 + 2.67 + cam_fov(vfov); 2.68 + 2.69 gl_matrix_mode(GL_PROJECTION); 2.70 gl_load_identity(); 2.71 - glu_perspective(40.0, (float)x / (float)y, 0.5, 500.0); 2.72 + glu_perspective(vfov, aspect, 0.5, 500.0); 2.73 2.74 view_xsz = x; 2.75 view_ysz = y;