Merge pull request #15 from bjornbytes/linux

Linux Support
This commit is contained in:
Bjorn Swenson 2017-08-03 01:23:30 -07:00 committed by GitHub
commit e775b3f63d
5 changed files with 68 additions and 6 deletions

View File

@ -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)

View File

@ -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
---

View File

@ -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);

View File

@ -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;

View File

@ -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