oculus2
changeset 10:3d224ad45cac
linux fixes
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 26 Oct 2014 23:10:14 +0200 |
parents | 9c36ae39ad95 |
children | 256d8fcf02f1 |
files | Makefile src/main.c |
diffstat | 2 files changed, 16 insertions(+), 3 deletions(-) [+] |
line diff
1.1 --- a/Makefile Sat Oct 25 20:07:55 2014 +0300 1.2 +++ b/Makefile Sun Oct 26 23:10:14 2014 +0200 1.3 @@ -3,7 +3,7 @@ 1.4 bin = oculus2 1.5 1.6 CFLAGS = -pedantic -Wall -g `pkg-config --cflags sdl2` 1.7 -LDFLAGS = $(libgl) `pkg-config --libs sdl2` -lovr 1.8 +LDFLAGS = $(libgl) `pkg-config --libs sdl2` -lovr -lX11 1.9 1.10 ifeq ($(shell uname -s), Darwin) 1.11 libgl = -framework OpenGL -lGLEW
2.1 --- a/src/main.c Sat Oct 25 20:07:55 2014 +0300 2.2 +++ b/src/main.c Sun Oct 26 23:10:14 2014 +0200 2.3 @@ -11,12 +11,15 @@ 2.4 #include <assert.h> 2.5 #include <SDL2/SDL.h> 2.6 #include <GL/glew.h> 2.7 +#include <X11/Xlib.h> 2.8 +#include <GL/glx.h> 2.9 2.10 #ifdef WIN32 2.11 #define OVR_OS_WIN32 2.12 -#endif 2.13 -#ifdef __APPLE__ 2.14 +#elif defined(__APPLE__) 2.15 #define OVR_OS_MAC 2.16 +#else 2.17 +#define OVR_OS_LINUX 2.18 #endif 2.19 2.20 #include <OVR_CAPI.h> 2.21 @@ -99,6 +102,8 @@ 2.22 return -1; 2.23 } 2.24 2.25 + XSynchronize(glXGetCurrentDisplay(), True); 2.26 + 2.27 glewInit(); 2.28 2.29 if(!(hmd = ovrHmd_Create(0))) { 2.30 @@ -160,6 +165,14 @@ 2.31 glcfg.OGL.Window = sys_win; 2.32 glcfg.OGL.DC = wglGetCurrentDC(); 2.33 ovrHmd_AttachToWindow(hmd, sys_win, 0, 0); 2.34 +#else 2.35 + Display *dpy = glXGetCurrentDisplay(); 2.36 + Window win = glXGetCurrentDrawable(); 2.37 + assert(dpy && win); 2.38 + 2.39 + glcfg.OGL.Disp = dpy; 2.40 + glcfg.OGL.Win = win; 2.41 + ovrHmd_AttachToWindow(hmd, (void*)win, 0, 0); 2.42 #endif 2.43 printf("running in \"direct-hmd\" mode\n"); 2.44 }