oculus2

diff src/main.c @ 3:096b18432ba7

something is fucked
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 26 Aug 2014 18:37:24 +0300
parents 0984fa94b490
children d64830551c32
line diff
     1.1 --- a/src/main.c	Tue Aug 26 08:14:09 2014 +0300
     1.2 +++ b/src/main.c	Tue Aug 26 18:37:24 2014 +0300
     1.3 @@ -114,13 +114,12 @@
     1.4  		fb_ovr_tex[i].OGL.Header.API = ovrRenderAPI_OpenGL;
     1.5  		fb_ovr_tex[i].OGL.Header.TextureSize.w = fb_tex_width;
     1.6  		fb_ovr_tex[i].OGL.Header.TextureSize.h = fb_tex_height;
     1.7 -		fb_ovr_tex[i].OGL.Header.RenderViewport.Pos.y = 0;
     1.8 +		fb_ovr_tex[i].OGL.Header.RenderViewport.Pos.x = i == 0 ? 0 : fb_width / 2.0;
     1.9 +		fb_ovr_tex[i].OGL.Header.RenderViewport.Pos.y = fb_tex_height - fb_height;
    1.10  		fb_ovr_tex[i].OGL.Header.RenderViewport.Size.w = fb_width / 2.0;
    1.11  		fb_ovr_tex[i].OGL.Header.RenderViewport.Size.h = fb_height;
    1.12  		fb_ovr_tex[i].OGL.TexId = fb_tex;
    1.13  	}
    1.14 -	fb_ovr_tex[0].OGL.Header.RenderViewport.Pos.x = 0;
    1.15 -	fb_ovr_tex[1].OGL.Header.RenderViewport.Pos.x = fb_width / 2.0;
    1.16  
    1.17  	memset(&glcfg, 0, sizeof glcfg);
    1.18  	glcfg.OGL.Header.API = ovrRenderAPI_OpenGL;
    1.19 @@ -140,20 +139,19 @@
    1.20  	}
    1.21  	ovrHmd_SetEnabledCaps(hmd, ovrHmdCap_LowPersistence | ovrHmdCap_DynamicPrediction);
    1.22  
    1.23 -	dcaps = ovrDistortionCap_Chromatic | ovrDistortionCap_Vignette | ovrDistortionCap_TimeWarp;
    1.24 +	dcaps = ovrDistortionCap_Chromatic | ovrDistortionCap_Vignette;// | ovrDistortionCap_TimeWarp;
    1.25  	if(!ovrHmd_ConfigureRendering(hmd, &glcfg.Config, dcaps, hmd->DefaultEyeFov, eye_rdesc)) {
    1.26  		fprintf(stderr, "failed to configure distortion renderer\n");
    1.27  	}
    1.28  
    1.29 -	/* ovrhmd_EnableHSWDisplaySDKRender(hmd, 0); */
    1.30 -
    1.31 +	ovrhmd_EnableHSWDisplaySDKRender(hmd, 0);
    1.32  
    1.33  	glEnable(GL_DEPTH_TEST);
    1.34  	glEnable(GL_CULL_FACE);
    1.35  	glEnable(GL_LIGHTING);
    1.36  	glEnable(GL_LIGHT0);
    1.37  
    1.38 -	glClearColor(0.5, 0.05, 0.05, 1);
    1.39 +	glClearColor(0.05, 0.05, 0.05, 1);
    1.40  
    1.41  	return 0;
    1.42  }
    1.43 @@ -179,6 +177,45 @@
    1.44  	glBindFramebuffer(GL_FRAMEBUFFER, fbo);
    1.45  	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    1.46  
    1.47 +	glViewport(0, 0, fb_width, fb_height);
    1.48 +
    1.49 +	/*glMatrixMode(GL_PROJECTION);
    1.50 +	glLoadIdentity();
    1.51 +	glMatrixMode(GL_MODELVIEW);
    1.52 +	glLoadIdentity();
    1.53 +
    1.54 +	glPushAttrib(GL_ENABLE_BIT);
    1.55 +	glDisable(GL_LIGHTING);
    1.56 +	glDisable(GL_DEPTH_TEST);
    1.57 +
    1.58 +	glBegin(GL_QUADS);
    1.59 +	glColor3f(1, 0, 0);
    1.60 +	glVertex2f(-1, -1);
    1.61 +	glVertex2f(0, -1);
    1.62 +	glVertex2f(0, 1);
    1.63 +	glVertex2f(-1, 1);
    1.64 +
    1.65 +	glColor3f(1, 0, 1);
    1.66 +	glVertex2f(-0.6, -0.1);
    1.67 +	glVertex2f(-0.4, -0.1);
    1.68 +	glVertex2f(-0.4, 0.1);
    1.69 +	glVertex2f(-0.6, 0.1);
    1.70 +
    1.71 +	glColor3f(0, 1, 0);
    1.72 +	glVertex2f(0, -1);
    1.73 +	glVertex2f(1, -1);
    1.74 +	glVertex2f(1, 1);
    1.75 +	glVertex2f(0, 1);
    1.76 +
    1.77 +	glColor3f(0, 1, 1);
    1.78 +	glVertex2f(0.4, -0.1);
    1.79 +	glVertex2f(0.6, -0.1);
    1.80 +	glVertex2f(0.6, 0.1);
    1.81 +	glVertex2f(0.4, 0.1);
    1.82 +	glEnd();
    1.83 +
    1.84 +	glPopAttrib();*/
    1.85 +
    1.86  	/* for each eye ... */
    1.87  	for(i=0; i<2; i++) {
    1.88  		int eye = hmd->EyeRenderOrder[i];
    1.89 @@ -188,12 +225,14 @@
    1.90  
    1.91  		proj = ovrMatrix4f_Projection(hmd->DefaultEyeFov[eye], 0.5, 500.0, 1);
    1.92  		glMatrixMode(GL_PROJECTION);
    1.93 -		glLoadMatrixf(proj.M[0]);
    1.94 +		//glLoadMatrixf(proj.M[0]);
    1.95 +		glLoadIdentity();
    1.96 +		gluPerspective(50.0, (float)fb_width / 2.0 / (float)fb_height, 0.5, 500.0);
    1.97  
    1.98  		pose[eye] = ovrHmd_GetEyePose(hmd, eye);
    1.99  		glMatrixMode(GL_MODELVIEW);
   1.100 -		/* TODO: get HMD orientation data and use them */
   1.101 -		glTranslatef(0, -ovrHmd_GetFloat(hmd, OVR_KEY_EYE_HEIGHT, 1.65), 0);
   1.102 +		/* TODO: get HMD orientation data and use it */
   1.103 +		//glTranslatef(0, -ovrHmd_GetFloat(hmd, OVR_KEY_EYE_HEIGHT, 1.65), 0);
   1.104  
   1.105  		draw_scene();
   1.106  	}
   1.107 @@ -212,6 +251,11 @@
   1.108  	float lpos[] = {0, 5, 0, 1};
   1.109  	glLightfv(GL_LIGHT0, GL_POSITION, lpos);
   1.110  
   1.111 +	glPushMatrix();
   1.112 +	glTranslatef(0, 0, -8);
   1.113 +	draw_box(2, 2, 2, 1.0);
   1.114 +	glPopMatrix();
   1.115 +
   1.116  	glTranslatef(0, 5, 0);
   1.117  	draw_box(20, 10, 20, -1.0);
   1.118