libgoatvr

diff example/src/main.c @ 19:437fe32ac633

ops... wasn't handling the stereo eye separation correctly. also fixed a bug in vr_libovr.c causing an assertion inside LibOVR when ovrHmd_GetEyePose was called as a result of calls to view_rotation or view_translation outside of vr_begin/vr_end
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 04 Oct 2014 03:39:14 +0300
parents 34d4643d61f9
children 5136dfcea7b1
line diff
     1.1 --- a/example/src/main.c	Fri Oct 03 23:07:27 2014 +0300
     1.2 +++ b/example/src/main.c	Sat Oct 04 03:39:14 2014 +0300
     1.3 @@ -155,7 +155,7 @@
     1.4  		 * rendering the left eye's view (0, 0, width/2, height), and in the right half
     1.5  		 * of the framebuffer for the right eye's view (width/2, 0, width/2, height)
     1.6  		 */
     1.7 -		glViewport(i == 0 ? 0 : fb_width / 2, 0, fb_width / 2, fb_height);
     1.8 +		glViewport(i == VR_EYE_LEFT ? 0 : fb_width / 2, 0, fb_width / 2, fb_height);
     1.9  
    1.10  		glMatrixMode(GL_PROJECTION);
    1.11  		/* -- projection transformation --
    1.12 @@ -249,11 +249,19 @@
    1.13  		draw_box(0.5, 0.5, 0.5, 1.0);
    1.14  		glPopMatrix();
    1.15  	}
    1.16 +
    1.17 +	col[0] = 1;
    1.18 +	col[1] = 1;
    1.19 +	col[2] = 0.4;
    1.20 +	glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, col);
    1.21 +	draw_box(0.05, 1.2, 6, 1.0);
    1.22 +	draw_box(6, 1.2, 0.05, 1.0);
    1.23  }
    1.24  
    1.25  void draw_box(float xsz, float ysz, float zsz, float norm_sign)
    1.26  {
    1.27  	glMatrixMode(GL_MODELVIEW);
    1.28 +	glPushMatrix();
    1.29  	glScalef(xsz * 0.5, ysz * 0.5, zsz * 0.5);
    1.30  
    1.31  	if(norm_sign < 0.0) {
    1.32 @@ -302,6 +310,7 @@
    1.33  	glEnd();
    1.34  
    1.35  	glFrontFace(GL_CCW);
    1.36 +	glPopMatrix();
    1.37  }
    1.38  
    1.39  /* update_rtarg creates (and/or resizes) the render target used to draw the two stero views */