oculus2_psprite

changeset 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
files oculus2.vcxproj src/main.c
diffstat 2 files changed, 56 insertions(+), 12 deletions(-) [+]
line diff
     1.1 --- a/oculus2.vcxproj	Tue Aug 26 08:14:09 2014 +0300
     1.2 +++ b/oculus2.vcxproj	Tue Aug 26 18:37:24 2014 +0300
     1.3 @@ -57,7 +57,7 @@
     1.4      <Link>
     1.5        <SubSystem>Console</SubSystem>
     1.6        <GenerateDebugInformation>true</GenerateDebugInformation>
     1.7 -      <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;sdl2.lib;sdl2main.lib;opengl32.lib;glew32.lib;libovrd.lib;winmm.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
     1.8 +      <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;sdl2.lib;sdl2main.lib;opengl32.lib;glu32.lib;glew32.lib;libovrd.lib;winmm.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
     1.9      </Link>
    1.10    </ItemDefinitionGroup>
    1.11    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    1.12 @@ -76,7 +76,7 @@
    1.13        <GenerateDebugInformation>true</GenerateDebugInformation>
    1.14        <EnableCOMDATFolding>true</EnableCOMDATFolding>
    1.15        <OptimizeReferences>true</OptimizeReferences>
    1.16 -      <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;sdl2.lib;sdl2main.lib;opengl32.lib;glew32.lib;libovr.lib;winmm.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
    1.17 +      <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;sdl2.lib;sdl2main.lib;opengl32.lib;glu32.lib;glew32.lib;libovr.lib;winmm.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
    1.18      </Link>
    1.19    </ItemDefinitionGroup>
    1.20    <ItemGroup>
     2.1 --- a/src/main.c	Tue Aug 26 08:14:09 2014 +0300
     2.2 +++ b/src/main.c	Tue Aug 26 18:37:24 2014 +0300
     2.3 @@ -114,13 +114,12 @@
     2.4  		fb_ovr_tex[i].OGL.Header.API = ovrRenderAPI_OpenGL;
     2.5  		fb_ovr_tex[i].OGL.Header.TextureSize.w = fb_tex_width;
     2.6  		fb_ovr_tex[i].OGL.Header.TextureSize.h = fb_tex_height;
     2.7 -		fb_ovr_tex[i].OGL.Header.RenderViewport.Pos.y = 0;
     2.8 +		fb_ovr_tex[i].OGL.Header.RenderViewport.Pos.x = i == 0 ? 0 : fb_width / 2.0;
     2.9 +		fb_ovr_tex[i].OGL.Header.RenderViewport.Pos.y = fb_tex_height - fb_height;
    2.10  		fb_ovr_tex[i].OGL.Header.RenderViewport.Size.w = fb_width / 2.0;
    2.11  		fb_ovr_tex[i].OGL.Header.RenderViewport.Size.h = fb_height;
    2.12  		fb_ovr_tex[i].OGL.TexId = fb_tex;
    2.13  	}
    2.14 -	fb_ovr_tex[0].OGL.Header.RenderViewport.Pos.x = 0;
    2.15 -	fb_ovr_tex[1].OGL.Header.RenderViewport.Pos.x = fb_width / 2.0;
    2.16  
    2.17  	memset(&glcfg, 0, sizeof glcfg);
    2.18  	glcfg.OGL.Header.API = ovrRenderAPI_OpenGL;
    2.19 @@ -140,20 +139,19 @@
    2.20  	}
    2.21  	ovrHmd_SetEnabledCaps(hmd, ovrHmdCap_LowPersistence | ovrHmdCap_DynamicPrediction);
    2.22  
    2.23 -	dcaps = ovrDistortionCap_Chromatic | ovrDistortionCap_Vignette | ovrDistortionCap_TimeWarp;
    2.24 +	dcaps = ovrDistortionCap_Chromatic | ovrDistortionCap_Vignette;// | ovrDistortionCap_TimeWarp;
    2.25  	if(!ovrHmd_ConfigureRendering(hmd, &glcfg.Config, dcaps, hmd->DefaultEyeFov, eye_rdesc)) {
    2.26  		fprintf(stderr, "failed to configure distortion renderer\n");
    2.27  	}
    2.28  
    2.29 -	/* ovrhmd_EnableHSWDisplaySDKRender(hmd, 0); */
    2.30 -
    2.31 +	ovrhmd_EnableHSWDisplaySDKRender(hmd, 0);
    2.32  
    2.33  	glEnable(GL_DEPTH_TEST);
    2.34  	glEnable(GL_CULL_FACE);
    2.35  	glEnable(GL_LIGHTING);
    2.36  	glEnable(GL_LIGHT0);
    2.37  
    2.38 -	glClearColor(0.5, 0.05, 0.05, 1);
    2.39 +	glClearColor(0.05, 0.05, 0.05, 1);
    2.40  
    2.41  	return 0;
    2.42  }
    2.43 @@ -179,6 +177,45 @@
    2.44  	glBindFramebuffer(GL_FRAMEBUFFER, fbo);
    2.45  	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    2.46  
    2.47 +	glViewport(0, 0, fb_width, fb_height);
    2.48 +
    2.49 +	/*glMatrixMode(GL_PROJECTION);
    2.50 +	glLoadIdentity();
    2.51 +	glMatrixMode(GL_MODELVIEW);
    2.52 +	glLoadIdentity();
    2.53 +
    2.54 +	glPushAttrib(GL_ENABLE_BIT);
    2.55 +	glDisable(GL_LIGHTING);
    2.56 +	glDisable(GL_DEPTH_TEST);
    2.57 +
    2.58 +	glBegin(GL_QUADS);
    2.59 +	glColor3f(1, 0, 0);
    2.60 +	glVertex2f(-1, -1);
    2.61 +	glVertex2f(0, -1);
    2.62 +	glVertex2f(0, 1);
    2.63 +	glVertex2f(-1, 1);
    2.64 +
    2.65 +	glColor3f(1, 0, 1);
    2.66 +	glVertex2f(-0.6, -0.1);
    2.67 +	glVertex2f(-0.4, -0.1);
    2.68 +	glVertex2f(-0.4, 0.1);
    2.69 +	glVertex2f(-0.6, 0.1);
    2.70 +
    2.71 +	glColor3f(0, 1, 0);
    2.72 +	glVertex2f(0, -1);
    2.73 +	glVertex2f(1, -1);
    2.74 +	glVertex2f(1, 1);
    2.75 +	glVertex2f(0, 1);
    2.76 +
    2.77 +	glColor3f(0, 1, 1);
    2.78 +	glVertex2f(0.4, -0.1);
    2.79 +	glVertex2f(0.6, -0.1);
    2.80 +	glVertex2f(0.6, 0.1);
    2.81 +	glVertex2f(0.4, 0.1);
    2.82 +	glEnd();
    2.83 +
    2.84 +	glPopAttrib();*/
    2.85 +
    2.86  	/* for each eye ... */
    2.87  	for(i=0; i<2; i++) {
    2.88  		int eye = hmd->EyeRenderOrder[i];
    2.89 @@ -188,12 +225,14 @@
    2.90  
    2.91  		proj = ovrMatrix4f_Projection(hmd->DefaultEyeFov[eye], 0.5, 500.0, 1);
    2.92  		glMatrixMode(GL_PROJECTION);
    2.93 -		glLoadMatrixf(proj.M[0]);
    2.94 +		//glLoadMatrixf(proj.M[0]);
    2.95 +		glLoadIdentity();
    2.96 +		gluPerspective(50.0, (float)fb_width / 2.0 / (float)fb_height, 0.5, 500.0);
    2.97  
    2.98  		pose[eye] = ovrHmd_GetEyePose(hmd, eye);
    2.99  		glMatrixMode(GL_MODELVIEW);
   2.100 -		/* TODO: get HMD orientation data and use them */
   2.101 -		glTranslatef(0, -ovrHmd_GetFloat(hmd, OVR_KEY_EYE_HEIGHT, 1.65), 0);
   2.102 +		/* TODO: get HMD orientation data and use it */
   2.103 +		//glTranslatef(0, -ovrHmd_GetFloat(hmd, OVR_KEY_EYE_HEIGHT, 1.65), 0);
   2.104  
   2.105  		draw_scene();
   2.106  	}
   2.107 @@ -212,6 +251,11 @@
   2.108  	float lpos[] = {0, 5, 0, 1};
   2.109  	glLightfv(GL_LIGHT0, GL_POSITION, lpos);
   2.110  
   2.111 +	glPushMatrix();
   2.112 +	glTranslatef(0, 0, -8);
   2.113 +	draw_box(2, 2, 2, 1.0);
   2.114 +	glPopMatrix();
   2.115 +
   2.116  	glTranslatef(0, 5, 0);
   2.117  	draw_box(20, 10, 20, -1.0);
   2.118