oculus2

changeset 11:256d8fcf02f1

wtf... nothing is drawn on linux
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 27 Oct 2014 04:20:07 +0200
parents 3d224ad45cac
children 4c08bc24ef0a 62a37bd5bc74
files src/main.c
diffstat 1 files changed, 12 insertions(+), 15 deletions(-) [+]
line diff
     1.1 --- a/src/main.c	Sun Oct 26 23:10:14 2014 +0200
     1.2 +++ b/src/main.c	Mon Oct 27 04:20:07 2014 +0200
     1.3 @@ -102,8 +102,6 @@
     1.4  		return -1;
     1.5  	}
     1.6  
     1.7 -	XSynchronize(glXGetCurrentDisplay(), True);
     1.8 -
     1.9  	glewInit();
    1.10  
    1.11  	if(!(hmd = ovrHmd_Create(0))) {
    1.12 @@ -121,8 +119,8 @@
    1.13  	win_width = hmd->Resolution.w;
    1.14  	win_height = hmd->Resolution.h;
    1.15  
    1.16 -	/* enable position and rotation tracking (and anything else they might add in the future) */
    1.17 -	ovrHmd_ConfigureTracking(hmd, 0xffffffff, 0);
    1.18 +	/* enable position and rotation tracking */
    1.19 +	ovrHmd_ConfigureTracking(hmd, ovrTrackingCap_Orientation | ovrTrackingCap_MagYawCorrection | ovrTrackingCap_Position, 0);
    1.20  	/* retrieve the optimal render target resolution for each eye */
    1.21  	eyeres[0] = ovrHmd_GetFovTextureSize(hmd, ovrEye_Left, hmd->DefaultEyeFov[0], 1.0);
    1.22  	eyeres[1] = ovrHmd_GetFovTextureSize(hmd, ovrEye_Right, hmd->DefaultEyeFov[1], 1.0);
    1.23 @@ -153,6 +151,14 @@
    1.24  	glcfg.OGL.Header.RTSize = hmd->Resolution;
    1.25  	glcfg.OGL.Header.Multisample = 1;
    1.26  
    1.27 +#ifdef WIN32
    1.28 +	glcfg.OGL.Window = GetActiveWindow();
    1.29 +	glcfg.OGL.DC = wglGetCurrentDC();
    1.30 +#else
    1.31 +	glcfg.OGL.Disp = glXGetCurrentDisplay();
    1.32 +	glcfg.OGL.Win = glXGetCurrentDrawable();
    1.33 +#endif
    1.34 +
    1.35  	if(hmd->HmdCaps & ovrHmdCap_ExtendDesktop) {
    1.36  		printf("running in \"extended desktop\" mode\n");
    1.37  	} else {
    1.38 @@ -161,18 +167,9 @@
    1.39  		 * XXX: this doesn't work properly yet due to bugs in the oculus 0.4.1 sdk/driver
    1.40  		 */
    1.41  #ifdef WIN32
    1.42 -		HWND sys_win = GetActiveWindow();
    1.43 -		glcfg.OGL.Window = sys_win;
    1.44 -		glcfg.OGL.DC = wglGetCurrentDC();
    1.45 -		ovrHmd_AttachToWindow(hmd, sys_win, 0, 0);
    1.46 +		ovrHmd_AttachToWindow(hmd, glcfg.OGL.Window, 0, 0);
    1.47  #else
    1.48 -		Display *dpy = glXGetCurrentDisplay();
    1.49 -		Window win = glXGetCurrentDrawable();
    1.50 -		assert(dpy && win);
    1.51 -
    1.52 -		glcfg.OGL.Disp = dpy;
    1.53 -		glcfg.OGL.Win = win;
    1.54 -		ovrHmd_AttachToWindow(hmd, (void*)win, 0, 0);
    1.55 +		ovrHmd_AttachToWindow(hmd, (void*)glcfg.OGL.Win, 0, 0);
    1.56  #endif
    1.57  		printf("running in \"direct-hmd\" mode\n");
    1.58  	}