From b4513d5ca6f5b9e3fcdec4234f0f0a3df55dd728 Mon Sep 17 00:00:00 2001 From: bjorn Date: Tue, 1 Aug 2017 12:23:33 -0700 Subject: [PATCH 1/5] Fixes for lovr.filesystem on Linux; --- src/filesystem/filesystem.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/filesystem/filesystem.c b/src/filesystem/filesystem.c index c501ac5c..9ebe7a3b 100644 --- a/src/filesystem/filesystem.c +++ b/src/filesystem/filesystem.c @@ -81,6 +81,13 @@ int lovrFilesystemGetAppdataDirectory(char* dest, unsigned int size) { #elif EMSCRIPTEN strncpy(dest, "/home/web_user", size); return 0; +#elif __linux__ + const char* home; + if ((home = getenv("HOME")) == NULL) { + home = getpwuid(getuid())->pw_dir; + } + + snprintf(dest, size, "%s/.config", home); #else #error "This platform is missing an implementation for lovrFilesystemGetAppdataDirectory" #endif @@ -101,6 +108,11 @@ int lovrFilesystemGetExecutablePath(char* dest, unsigned int size) { return !GetModuleFileName(NULL, dest, size); #elif EMSCRIPTEN return 1; +#elif __linux__ + memset(dest, 0, size); + if (readlink("/proc/self/exe", dest, size) == -1) { + perror("readlink"); + } #else #error "This platform is missing an implementation for lovrFilesystemGetExecutablePath" #endif @@ -213,10 +225,12 @@ int lovrFilesystemSetIdentity(const char* identity) { lovrFilesystemGetAppdataDirectory(state.savePathFull, LOVR_PATH_MAX); PHYSFS_setWriteDir(state.savePathFull); snprintf(state.savePathRelative, LOVR_PATH_MAX, "LOVR/%s", identity ? identity : "default"); - snprintf(state.savePathFull, LOVR_PATH_MAX, "%s/%s", state.savePathFull, state.savePathRelative); + char fullPathBuffer[LOVR_PATH_MAX]; + snprintf(fullPathBuffer, LOVR_PATH_MAX, "%s/%s", state.savePathFull, state.savePathRelative); + strncpy(state.savePathFull, fullPathBuffer, LOVR_PATH_MAX); PHYSFS_mkdir(state.savePathRelative); if (!PHYSFS_setWriteDir(state.savePathFull)) { - error("Could not set write directory"); + error("Could not set write directory: %s (%s)", PHYSFS_getLastError(), state.savePathRelative); } PHYSFS_mount(state.savePathFull, NULL, 0); From d398012bd635ae2f367f220928d01acc94523744 Mon Sep 17 00:00:00 2001 From: bjorn Date: Thu, 3 Aug 2017 00:32:10 -0700 Subject: [PATCH 2/5] Add Linux compilation instructions; --- COMPILING.md | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/COMPILING.md b/COMPILING.md index 7bb34910..df95bd3a 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -28,7 +28,7 @@ cd lovr git clone --recursive https://github.com/bjornbytes/lovr-deps deps ``` -Windows (CMake) +Windows --- From the `lovr` folder, run these commands to create a build folder and compile the project using @@ -45,7 +45,7 @@ The executable will then exist at `/path/to/lovr/build/Debug/lovr.exe`. A LÖVR containing a `main.lua` script) can then be dropped onto `lovr.exe` to run it, or it can be run via the command line as `lovr.exe path/to/project`. -Unix (CMake) +Unix --- Install the dependencies using your package manager of choice: @@ -70,6 +70,43 @@ symlink so that this executable exists on your path. Once that's done, you can lovr /path/to/myGame ``` +Linux +--- + +On Arch Linux, first install necessary dependencies: + +```sh +pacman -S assimp glfw-x11 luajit physfs freetype2 openal ode +``` + +Then, build with CMake: + +```sh +mkdir build +cd build +cmake .. +cmake --build . +``` + +On Linux, LÖVR needs to run within the Steam Runtime. To do this, first [install +Steam](https://wiki.archlinux.org/index.php/Steam#Installation). Next, [install the Steam udev +rules](https://github.com/ValveSoftware/SteamVR-for-Linux#usb-device-requirements). Then, run LÖVR +within the Steam runtime: + +```sh +~/.steam/steam/ubuntu12_32/steam-runtime/run.sh lovr +``` + +If you receive errors related to `libstdc++`, set the `LD_PRELOAD` environment variable when running +the command: + +```sh +LD_PRELOAD='/usr/$LIB/libstdc++.so.6 /usr/$LIB/libgcc_s.so.1' ~/.steam/steam/ubuntu12_32/steam-runtime/run.sh lovr +``` + +Currently, there are performance issues between SteamVR and OpenGL apps. These are being rapidly +resolved with newer versions of graphics drivers and SteamVR. + WebVR --- From 56620934510031e685ce0b91703433929d7c1370 Mon Sep 17 00:00:00 2001 From: bjorn Date: Thu, 3 Aug 2017 00:32:31 -0700 Subject: [PATCH 3/5] Fix enet CMake for Linux; --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 033def3a..ab73a620 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,8 +48,8 @@ else() endif() # enet -set(HAVE_HAS_SOCKLEN_T TRUE CACHE BOOL "") if(EMSCRIPTEN) + set(HAVE_HAS_SOCKLEN_T TRUE CACHE BOOL "") add_definitions(-D__APPLE__) add_subdirectory(deps/enet enet) include_directories(deps/enet/include) From 4e81bc6cd9d115a92787738da34e7c44134a9a88 Mon Sep 17 00:00:00 2001 From: bjorn Date: Thu, 3 Aug 2017 00:33:07 -0700 Subject: [PATCH 4/5] Fix Linux glad include; --- src/lib/glfw.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/glfw.h b/src/lib/glfw.h index 73d68f8e..c23be6e7 100644 --- a/src/lib/glfw.h +++ b/src/lib/glfw.h @@ -5,9 +5,11 @@ #define GLFW_INCLUDE_GLEXT #elif __APPLE__ #define GLFW_INCLUDE_GLCOREARB -#include "glad/glad.h" #elif _WIN32 #define APIENTRY __stdcall +#endif + +#ifndef EMSCRIPTEN #include "glad/glad.h" #endif From b5a58e31f1d519121dbb4971fab445e4fd7114cf Mon Sep 17 00:00:00 2001 From: bjorn Date: Thu, 3 Aug 2017 00:35:46 -0700 Subject: [PATCH 5/5] Declare secret OpenVR functions; --- src/headset/openvr.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/headset/openvr.h b/src/headset/openvr.h index ecad716e..681e6566 100644 --- a/src/headset/openvr.h +++ b/src/headset/openvr.h @@ -9,6 +9,15 @@ #pragma once +// From openvr_capi.h +extern intptr_t VR_InitInternal(EVRInitError *peError, EVRApplicationType eType); +extern void VR_ShutdownInternal(); +extern bool VR_IsHmdPresent(); +extern intptr_t VR_GetGenericInterface(const char* pchInterfaceVersion, EVRInitError* peError); +extern bool VR_IsRuntimeInstalled(); +extern const char* VR_GetVRInitErrorAsSymbol(EVRInitError error); +extern const char* VR_GetVRInitErrorAsEnglishDescription(EVRInitError error); + typedef struct { int isInitialized; int isRendering;