oculus2_psprite

diff src/main.c @ 10:3d224ad45cac

linux fixes
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 26 Oct 2014 23:10:14 +0200
parents 9c36ae39ad95
children 256d8fcf02f1
line diff
     1.1 --- a/src/main.c	Sat Oct 25 20:07:55 2014 +0300
     1.2 +++ b/src/main.c	Sun Oct 26 23:10:14 2014 +0200
     1.3 @@ -11,12 +11,15 @@
     1.4  #include <assert.h>
     1.5  #include <SDL2/SDL.h>
     1.6  #include <GL/glew.h>
     1.7 +#include <X11/Xlib.h>
     1.8 +#include <GL/glx.h>
     1.9  
    1.10  #ifdef WIN32
    1.11  #define OVR_OS_WIN32
    1.12 -#endif
    1.13 -#ifdef __APPLE__
    1.14 +#elif defined(__APPLE__)
    1.15  #define OVR_OS_MAC
    1.16 +#else
    1.17 +#define OVR_OS_LINUX
    1.18  #endif
    1.19  
    1.20  #include <OVR_CAPI.h>
    1.21 @@ -99,6 +102,8 @@
    1.22  		return -1;
    1.23  	}
    1.24  
    1.25 +	XSynchronize(glXGetCurrentDisplay(), True);
    1.26 +
    1.27  	glewInit();
    1.28  
    1.29  	if(!(hmd = ovrHmd_Create(0))) {
    1.30 @@ -160,6 +165,14 @@
    1.31  		glcfg.OGL.Window = sys_win;
    1.32  		glcfg.OGL.DC = wglGetCurrentDC();
    1.33  		ovrHmd_AttachToWindow(hmd, sys_win, 0, 0);
    1.34 +#else
    1.35 +		Display *dpy = glXGetCurrentDisplay();
    1.36 +		Window win = glXGetCurrentDrawable();
    1.37 +		assert(dpy && win);
    1.38 +
    1.39 +		glcfg.OGL.Disp = dpy;
    1.40 +		glcfg.OGL.Win = win;
    1.41 +		ovrHmd_AttachToWindow(hmd, (void*)win, 0, 0);
    1.42  #endif
    1.43  		printf("running in \"direct-hmd\" mode\n");
    1.44  	}