# HG changeset patch # User John Tsiombikas # Date 1411221162 -10800 # Node ID d12592558809a7270f1eca565b11caf0ae730ce6 # Parent 3d9ec6fe97d7cb51ffc6cc1e3323787fc3f13906 build on macosx diff -r 3d9ec6fe97d7 -r d12592558809 Makefile.in --- a/Makefile.in Sat Sep 20 13:22:53 2014 +0300 +++ b/Makefile.in Sat Sep 20 16:52:42 2014 +0300 @@ -15,25 +15,31 @@ endif CFLAGS = -pedantic -Wall $(dbg) $(opt) $(pic) $(mod_cflags) -LDFLAGS = $(mod_libs) +LDFLAGS = $(mod_libs) $(libgl) lib_a = lib$(name).a ifeq ($(shell uname -s), Darwin) lib_so = lib$(name).dylib shared = -dynamiclib + libgl = -framework OpenGL + + ifdef use_libovr + mod_libs += -framework Cocoa -framework IOKit + endif else ldname = lib$(name).so soname = lib$(name).so.$(so_major) lib_so = lib$(name).so.$(so_major).$(so_minor) shared = -shared -Wl,-soname=$(soname) pic = -fPIC + libgl = -lGL -lGLU endif .PHONY: all all: $(lib_so) $(lib_a) $(soname) $(ldname) $(lib_so): $(obj) - $(CC) -o $@ $(shared) $(obj) $(LDFLAGS) + $(CXX) -o $@ $(shared) $(obj) $(LDFLAGS) $(soname): $(lib_so) ln -sf $< $@ diff -r 3d9ec6fe97d7 -r d12592558809 example/Makefile --- a/example/Makefile Sat Sep 20 13:22:53 2014 +0300 +++ b/example/Makefile Sat Sep 20 16:52:42 2014 +0300 @@ -5,11 +5,14 @@ vrlib_root = .. vrlib = $(vrlib_root)/libgoatvr.so -CFLAGS = -pedantic -Wall -g `pkg-config --cflags sdl2` -I$(vrlib_root)/src -LDFLAGS = $(libgl) `pkg-config --libs sdl2` -L$(vrlib_root) -lgoatvr -Wl,-rpath=$(vrlib_root) +warn = -Wall + +CFLAGS = -pedantic $(warn) -g `pkg-config --cflags sdl2` -I$(vrlib_root)/src +LDFLAGS = $(libgl) `pkg-config --libs sdl2` -L$(vrlib_root) -lgoatvr -Wl,-rpath -Wl,$(vrlib_root)/ ifeq ($(shell uname -s), Darwin) libgl = -framework OpenGL -lGLEW + warn += -Wno-deprecated-declarations else libgl = -lGL -lGLU -lGLEW endif diff -r 3d9ec6fe97d7 -r d12592558809 src/mesh.c --- a/src/mesh.c Sat Sep 20 13:22:53 2014 +0300 +++ b/src/mesh.c Sat Sep 20 16:52:42 2014 +0300 @@ -1,6 +1,7 @@ #include #include #include +#include #include "opengl.h" #include "mesh.h" @@ -15,7 +16,7 @@ #define GL_STATIC_DRAW 0x88E4 #endif -#if !defined(GL_VERSION_1_5) || !defined(GL_GLEXT_PROTOTYPES) +#ifndef GL_VERSION_1_5 static void (*glGenBuffers)(GLsizei, GLuint*); static void (*glDeleteBuffers)(GLsizei, GLuint*); static void (*glBufferData)(GLenum, unsigned int, const GLvoid*, GLenum); @@ -31,6 +32,7 @@ m->num_verts = m->num_faces = 0; m->vbo = m->ibo = 0; +#ifndef GL_VERSION_1_5 if(!glGenBuffers) { glGenBuffers = vrimp_glfunc("glGenBuffersARB"); glDeleteBuffers = vrimp_glfunc("glDeleteBuffersARB"); @@ -42,6 +44,7 @@ return -1; } } +#endif return 0; } diff -r 3d9ec6fe97d7 -r d12592558809 src/opengl.c --- a/src/opengl.c Sat Sep 20 13:22:53 2014 +0300 +++ b/src/opengl.c Sat Sep 20 16:52:42 2014 +0300 @@ -12,7 +12,7 @@ { return glXGetProcAddress((const unsigned char*)name); } -#endif +#endif /* __unix__ */ #ifdef WIN32 void vrimp_swap_buffers(void) @@ -25,4 +25,20 @@ { return wglGetProcAddress(name); } -#endif +#endif /* WIN32 */ + +#ifdef __APPLE__ +void vrimp_swap_buffers(void) +{ + /* TODO: I don't think this can even be done without obj-c and a pointer + * to a GLView class or whatever the fuck it's called... investigate further + */ +} + + +void (*vrimp_glfunc(const char *name))() +{ + /* TODO: whatever */ + return 0; +} +#endif /* __APPLE__ */ diff -r 3d9ec6fe97d7 -r d12592558809 src/vr_libovr.c --- a/src/vr_libovr.c Sat Sep 20 13:22:53 2014 +0300 +++ b/src/vr_libovr.c Sat Sep 20 16:52:42 2014 +0300 @@ -1,12 +1,16 @@ #ifdef WIN32 #define OVR_OS_WIN32 #endif +#ifdef __APPLE__ +#define OVR_OS_MAC +#endif #include "vr_impl.h" #ifdef USE_LIBOVR #include #include +#include #include #include "opt.h" @@ -30,6 +34,7 @@ static int init(void) { int i, num_hmds; + int use_fake = 0; if(!ovr_Initialize()) { return -1; @@ -37,15 +42,20 @@ printf("initialized LibOVR %s\n", ovr_GetVersionString()); if(!(num_hmds = ovrHmd_Detect())) { - ovr_Shutdown(); - return -1; + if(getenv("VR_LIBOVR_FAKE")) { + use_fake = 1; + num_hmds = 1; + } else { + ovr_Shutdown(); + return -1; + } } printf("%d Oculus HMD(s) found\n", num_hmds); hmd = 0; for(i=0; iManufacturer, h->ProductName); @@ -166,15 +176,13 @@ { if(!hmd) { vec[0] = vec[1] = vec[2] = 0; - return 0; + return; } pose[eye] = ovrHmd_GetEyePose(hmd, eye == VR_EYE_LEFT ? ovrEye_Left : ovrEye_Right); vec[0] = pose[eye].Position.x + eye_render_desc[eye].ViewAdjust.x; vec[1] = pose[eye].Position.y + eye_render_desc[eye].ViewAdjust.y; vec[2] = pose[eye].Position.z + eye_render_desc[eye].ViewAdjust.z; - - return 1; } static void rotation(int eye, float *quat) @@ -182,7 +190,7 @@ if(!hmd) { quat[0] = quat[1] = quat[2] = 0.0f; quat[3] = 1.0f; - return 0; + return; } pose[eye] = ovrHmd_GetEyePose(hmd, eye == VR_EYE_LEFT ? ovrEye_Left : ovrEye_Right); @@ -190,7 +198,6 @@ quat[1] = pose[eye].Orientation.y; quat[2] = pose[eye].Orientation.z; quat[3] = pose[eye].Orientation.w; - return 1; } static const float idmat[] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};