# HG changeset patch # User John Tsiombikas # Date 1409067444 -10800 # Node ID 096b18432ba7be6c04b2f80c582b91321a11a09d # Parent 0984fa94b490dac1af7b99807ecf6c2e187c401f something is fucked diff -r 0984fa94b490 -r 096b18432ba7 oculus2.vcxproj --- a/oculus2.vcxproj Tue Aug 26 08:14:09 2014 +0300 +++ b/oculus2.vcxproj Tue Aug 26 18:37:24 2014 +0300 @@ -57,7 +57,7 @@ Console true - 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) + 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) @@ -76,7 +76,7 @@ true true true - 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) + 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) diff -r 0984fa94b490 -r 096b18432ba7 src/main.c --- a/src/main.c Tue Aug 26 08:14:09 2014 +0300 +++ b/src/main.c Tue Aug 26 18:37:24 2014 +0300 @@ -114,13 +114,12 @@ fb_ovr_tex[i].OGL.Header.API = ovrRenderAPI_OpenGL; fb_ovr_tex[i].OGL.Header.TextureSize.w = fb_tex_width; fb_ovr_tex[i].OGL.Header.TextureSize.h = fb_tex_height; - fb_ovr_tex[i].OGL.Header.RenderViewport.Pos.y = 0; + fb_ovr_tex[i].OGL.Header.RenderViewport.Pos.x = i == 0 ? 0 : fb_width / 2.0; + fb_ovr_tex[i].OGL.Header.RenderViewport.Pos.y = fb_tex_height - fb_height; fb_ovr_tex[i].OGL.Header.RenderViewport.Size.w = fb_width / 2.0; fb_ovr_tex[i].OGL.Header.RenderViewport.Size.h = fb_height; fb_ovr_tex[i].OGL.TexId = fb_tex; } - fb_ovr_tex[0].OGL.Header.RenderViewport.Pos.x = 0; - fb_ovr_tex[1].OGL.Header.RenderViewport.Pos.x = fb_width / 2.0; memset(&glcfg, 0, sizeof glcfg); glcfg.OGL.Header.API = ovrRenderAPI_OpenGL; @@ -140,20 +139,19 @@ } ovrHmd_SetEnabledCaps(hmd, ovrHmdCap_LowPersistence | ovrHmdCap_DynamicPrediction); - dcaps = ovrDistortionCap_Chromatic | ovrDistortionCap_Vignette | ovrDistortionCap_TimeWarp; + dcaps = ovrDistortionCap_Chromatic | ovrDistortionCap_Vignette;// | ovrDistortionCap_TimeWarp; if(!ovrHmd_ConfigureRendering(hmd, &glcfg.Config, dcaps, hmd->DefaultEyeFov, eye_rdesc)) { fprintf(stderr, "failed to configure distortion renderer\n"); } - /* ovrhmd_EnableHSWDisplaySDKRender(hmd, 0); */ - + ovrhmd_EnableHSWDisplaySDKRender(hmd, 0); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); - glClearColor(0.5, 0.05, 0.05, 1); + glClearColor(0.05, 0.05, 0.05, 1); return 0; } @@ -179,6 +177,45 @@ glBindFramebuffer(GL_FRAMEBUFFER, fbo); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glViewport(0, 0, fb_width, fb_height); + + /*glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glPushAttrib(GL_ENABLE_BIT); + glDisable(GL_LIGHTING); + glDisable(GL_DEPTH_TEST); + + glBegin(GL_QUADS); + glColor3f(1, 0, 0); + glVertex2f(-1, -1); + glVertex2f(0, -1); + glVertex2f(0, 1); + glVertex2f(-1, 1); + + glColor3f(1, 0, 1); + glVertex2f(-0.6, -0.1); + glVertex2f(-0.4, -0.1); + glVertex2f(-0.4, 0.1); + glVertex2f(-0.6, 0.1); + + glColor3f(0, 1, 0); + glVertex2f(0, -1); + glVertex2f(1, -1); + glVertex2f(1, 1); + glVertex2f(0, 1); + + glColor3f(0, 1, 1); + glVertex2f(0.4, -0.1); + glVertex2f(0.6, -0.1); + glVertex2f(0.6, 0.1); + glVertex2f(0.4, 0.1); + glEnd(); + + glPopAttrib();*/ + /* for each eye ... */ for(i=0; i<2; i++) { int eye = hmd->EyeRenderOrder[i]; @@ -188,12 +225,14 @@ proj = ovrMatrix4f_Projection(hmd->DefaultEyeFov[eye], 0.5, 500.0, 1); glMatrixMode(GL_PROJECTION); - glLoadMatrixf(proj.M[0]); + //glLoadMatrixf(proj.M[0]); + glLoadIdentity(); + gluPerspective(50.0, (float)fb_width / 2.0 / (float)fb_height, 0.5, 500.0); pose[eye] = ovrHmd_GetEyePose(hmd, eye); glMatrixMode(GL_MODELVIEW); - /* TODO: get HMD orientation data and use them */ - glTranslatef(0, -ovrHmd_GetFloat(hmd, OVR_KEY_EYE_HEIGHT, 1.65), 0); + /* TODO: get HMD orientation data and use it */ + //glTranslatef(0, -ovrHmd_GetFloat(hmd, OVR_KEY_EYE_HEIGHT, 1.65), 0); draw_scene(); } @@ -212,6 +251,11 @@ float lpos[] = {0, 5, 0, 1}; glLightfv(GL_LIGHT0, GL_POSITION, lpos); + glPushMatrix(); + glTranslatef(0, 0, -8); + draw_box(2, 2, 2, 1.0); + glPopMatrix(); + glTranslatef(0, 5, 0); draw_box(20, 10, 20, -1.0);