mirror of https://github.com/bjornbytes/lovr.git
Windows fixes;
This commit is contained in:
parent
7550da44d8
commit
811bf67071
|
@ -56,7 +56,7 @@ endif()
|
||||||
# PhysicsFS
|
# PhysicsFS
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
add_subdirectory(deps/physfs physfs)
|
add_subdirectory(deps/physfs physfs)
|
||||||
include_directories(deps/physfs/src)
|
include_directories(deps/physfs)
|
||||||
set(LOVR_PHYSFS physfs)
|
set(LOVR_PHYSFS physfs)
|
||||||
else()
|
else()
|
||||||
find_package(PhysFS REQUIRED)
|
find_package(PhysFS REQUIRED)
|
||||||
|
|
|
@ -110,7 +110,7 @@ Next, build using CMake:
|
||||||
```sh
|
```sh
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake .. -DOPENVR_DIR=../../openvr
|
cmake .. -DOPENVR_DIR=../openvr
|
||||||
cmake --build .
|
cmake --build .
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,12 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <mach-o/dyld.h>
|
#include <mach-o/dyld.h>
|
||||||
|
#elif defined(WIN32)
|
||||||
|
#include <windows.h>
|
||||||
|
#include <initguid.h>
|
||||||
|
#include <KnownFolders.h>
|
||||||
|
#include <ShlObj.h>
|
||||||
|
#include <wchar.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static FilesystemState state;
|
static FilesystemState state;
|
||||||
|
@ -49,6 +55,8 @@ int lovrFilesystemGetExecutablePath(char* dest, unsigned int size) {
|
||||||
if (_NSGetExecutablePath(dest, &size) == 0) {
|
if (_NSGetExecutablePath(dest, &size) == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#elif defined(WIN32)
|
||||||
|
return !GetModuleFileName(NULL, dest, size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -146,6 +154,12 @@ int lovrFilesystemSetIdentity(const char* identity) {
|
||||||
PHYSFS_mount(state.savePathFull, NULL, 0);
|
PHYSFS_mount(state.savePathFull, NULL, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#elif defined(WIN32)
|
||||||
|
PWSTR appData = NULL;
|
||||||
|
SHGetKnownFolderPath(&FOLDERID_RoamingAppData, 0, NULL, &appData);
|
||||||
|
snprintf(state.savePathRelative, LOVR_PATH_MAX, "LOVR/%s", identity);
|
||||||
|
printf("%s %ls\n", state.savePathRelative, appData);
|
||||||
|
CoTaskMemFree(appData);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -38,7 +38,7 @@ void initGlfw(GLFWerrorfun onError, GLFWwindowclosefun onClose, void* userPointe
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glfwSetTime(0);
|
glfwSetTime(0);
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(0);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
|
|
|
@ -120,11 +120,11 @@ void lovrBufferGetVertex(Buffer* buffer, int index, void* dest) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(dest, buffer->data + index * buffer->stride, buffer->stride);
|
memcpy(dest, (char*) buffer->data + index * buffer->stride, buffer->stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lovrBufferSetVertex(Buffer* buffer, int index, void* data) {
|
void lovrBufferSetVertex(Buffer* buffer, int index, void* data) {
|
||||||
memcpy(buffer->data + index * buffer->stride, data, buffer->stride);
|
memcpy((char*) buffer->data + index * buffer->stride, data, buffer->stride);
|
||||||
|
|
||||||
glBindVertexArray(buffer->vao);
|
glBindVertexArray(buffer->vao);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
|
glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
|
||||||
|
|
|
@ -78,6 +78,7 @@ Headset* viveInit() {
|
||||||
VR_InitInternal(&vrError, EVRApplicationType_VRApplication_Scene);
|
VR_InitInternal(&vrError, EVRApplicationType_VRApplication_Scene);
|
||||||
|
|
||||||
if (vrError != EVRInitError_VRInitError_None) {
|
if (vrError != EVRInitError_VRInitError_None) {
|
||||||
|
printf("%d\n", vrError);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ int l_lovrFilesystemSetIdentity(lua_State* L) {
|
||||||
const char* identity = luaL_checkstring(L, 1);
|
const char* identity = luaL_checkstring(L, 1);
|
||||||
|
|
||||||
if (lovrFilesystemSetIdentity(identity)) {
|
if (lovrFilesystemSetIdentity(identity)) {
|
||||||
return luaL_error(L, "Could not set the filesystem identity");
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -490,7 +490,7 @@ int l_lovrGraphicsNewBuffer(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
*((float*) v) = value;
|
*((float*) v) = value;
|
||||||
v += sizeof(float);
|
v = (char*) v + sizeof(float);
|
||||||
} else if (attribute.type == BUFFER_BYTE) {
|
} else if (attribute.type == BUFFER_BYTE) {
|
||||||
unsigned char value = 255;
|
unsigned char value = 255;
|
||||||
if (tableIndex <= tableCount) {
|
if (tableIndex <= tableCount) {
|
||||||
|
@ -500,7 +500,7 @@ int l_lovrGraphicsNewBuffer(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
*((unsigned char*) v) = value;
|
*((unsigned char*) v) = value;
|
||||||
v += sizeof(unsigned char);
|
v = (char*) v + sizeof(unsigned char);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
|
|
||||||
void luax_pushbuffer(lua_State* L, Buffer* buffer) {
|
void luax_pushbuffer(lua_State* L, Buffer* buffer) {
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
return lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer** userdata = (Buffer**) lua_newuserdata(L, sizeof(Buffer*));
|
Buffer** userdata = (Buffer**) lua_newuserdata(L, sizeof(Buffer*));
|
||||||
|
@ -21,10 +22,10 @@ int luax_pushbuffervertex(lua_State* L, void* vertex, BufferFormat format) {
|
||||||
for (int j = 0; j < attribute.size; j++) {
|
for (int j = 0; j < attribute.size; j++) {
|
||||||
if (attribute.type == BUFFER_FLOAT) {
|
if (attribute.type == BUFFER_FLOAT) {
|
||||||
lua_pushnumber(L, *((float*)vertex));
|
lua_pushnumber(L, *((float*)vertex));
|
||||||
vertex += sizeof(float);
|
vertex = (char*) vertex + sizeof(float);
|
||||||
} else if (attribute.type == BUFFER_BYTE) {
|
} else if (attribute.type == BUFFER_BYTE) {
|
||||||
lua_pushnumber(L, *((unsigned char*)vertex));
|
lua_pushnumber(L, *((unsigned char*)vertex));
|
||||||
vertex += sizeof(unsigned char);
|
vertex = (char*) vertex + sizeof(unsigned char);
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
@ -143,7 +144,7 @@ int l_lovrBufferSetVertex(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
*((float*) v) = value;
|
*((float*) v) = value;
|
||||||
v += sizeof(float);
|
v = (char*) v + sizeof(float);
|
||||||
} else if (attribute.type == BUFFER_BYTE) {
|
} else if (attribute.type == BUFFER_BYTE) {
|
||||||
unsigned char value = 255;
|
unsigned char value = 255;
|
||||||
if (tableIndex <= tableCount) {
|
if (tableIndex <= tableCount) {
|
||||||
|
@ -153,7 +154,7 @@ int l_lovrBufferSetVertex(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
*((unsigned char*) v) = value;
|
*((unsigned char*) v) = value;
|
||||||
v += sizeof(unsigned char);
|
v = (char*) v + sizeof(unsigned char);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,10 +169,10 @@ int l_lovrBufferSetVertex(lua_State* L) {
|
||||||
for (int j = 0; j < attribute.size; j++) {
|
for (int j = 0; j < attribute.size; j++) {
|
||||||
if (attribute.type == BUFFER_FLOAT) {
|
if (attribute.type == BUFFER_FLOAT) {
|
||||||
*((float*) v) = argumentIndex <= argumentCount ? lua_tonumber(L, argumentIndex++) : 0.f;
|
*((float*) v) = argumentIndex <= argumentCount ? lua_tonumber(L, argumentIndex++) : 0.f;
|
||||||
v += sizeof(float);
|
v = (char*) v + sizeof(float);
|
||||||
} else if (attribute.type == BUFFER_BYTE) {
|
} else if (attribute.type == BUFFER_BYTE) {
|
||||||
*((char*) v) = argumentIndex <= argumentCount ? lua_tointeger(L, argumentIndex++) : 255;
|
*((char*) v) = argumentIndex <= argumentCount ? lua_tointeger(L, argumentIndex++) : 255;
|
||||||
v += sizeof(char);
|
v = (char*) v + sizeof(char);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,7 +218,7 @@ int l_lovrBufferSetVertexMap(lua_State* L) {
|
||||||
if (!lua_isnumber(L, -1)) {
|
if (!lua_isnumber(L, -1)) {
|
||||||
return luaL_error(L, "Buffer vertex map index #%d must be numeric", i);
|
return luaL_error(L, "Buffer vertex map index #%d must be numeric", i);
|
||||||
}
|
}
|
||||||
indices[i] = lua_tonumber(L, -1) - 1;
|
indices[i] = lua_tointeger(L, -1) - 1;
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
|
|
||||||
void luax_pushcontroller(lua_State* L, Controller* controller) {
|
void luax_pushcontroller(lua_State* L, Controller* controller) {
|
||||||
if (controller == NULL) {
|
if (controller == NULL) {
|
||||||
return lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller** userdata = (Controller**) lua_newuserdata(L, sizeof(Controller*));
|
Controller** userdata = (Controller**) lua_newuserdata(L, sizeof(Controller*));
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
void luax_pushmodel(lua_State* L, Model* model) {
|
void luax_pushmodel(lua_State* L, Model* model) {
|
||||||
if (model == NULL) {
|
if (model == NULL) {
|
||||||
return lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Model** userdata = (Model**) lua_newuserdata(L, sizeof(Model*));
|
Model** userdata = (Model**) lua_newuserdata(L, sizeof(Model*));
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
void luax_pushshader(lua_State* L, Shader* shader) {
|
void luax_pushshader(lua_State* L, Shader* shader) {
|
||||||
if (shader == NULL) {
|
if (shader == NULL) {
|
||||||
return lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Shader** userdata = (Shader**) lua_newuserdata(L, sizeof(Shader*));
|
Shader** userdata = (Shader**) lua_newuserdata(L, sizeof(Shader*));
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
void luax_pushskybox(lua_State* L, Skybox* skybox) {
|
void luax_pushskybox(lua_State* L, Skybox* skybox) {
|
||||||
if (skybox == NULL) {
|
if (skybox == NULL) {
|
||||||
return lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skybox** userdata = (Skybox**) lua_newuserdata(L, sizeof(Skybox*));
|
Skybox** userdata = (Skybox**) lua_newuserdata(L, sizeof(Skybox*));
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
|
|
||||||
void luax_pushtexture(lua_State* L, Texture* texture) {
|
void luax_pushtexture(lua_State* L, Texture* texture) {
|
||||||
if (texture == NULL) {
|
if (texture == NULL) {
|
||||||
return lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture** userdata = (Texture**) lua_newuserdata(L, sizeof(Texture*));
|
Texture** userdata = (Texture**) lua_newuserdata(L, sizeof(Texture*));
|
||||||
|
|
|
@ -17,7 +17,7 @@ static void assimpNodeTraversal(ModelNode* node, struct aiNode* assimpNode) {
|
||||||
|
|
||||||
// Children
|
// Children
|
||||||
vec_init(&node->children);
|
vec_init(&node->children);
|
||||||
for (int n = 0; n < assimpNode->mNumChildren; n++) {
|
for (unsigned int n = 0; n < assimpNode->mNumChildren; n++) {
|
||||||
ModelNode* child = malloc(sizeof(ModelNode));
|
ModelNode* child = malloc(sizeof(ModelNode));
|
||||||
assimpNodeTraversal(child, assimpNode->mChildren[n]);
|
assimpNodeTraversal(child, assimpNode->mChildren[n]);
|
||||||
vec_push(&node->children, child);
|
vec_push(&node->children, child);
|
||||||
|
@ -32,14 +32,14 @@ ModelData* lovrModelDataCreate(void* data, int size) {
|
||||||
|
|
||||||
// Meshes
|
// Meshes
|
||||||
vec_init(&modelData->meshes);
|
vec_init(&modelData->meshes);
|
||||||
for (int m = 0; m < scene->mNumMeshes; m++) {
|
for (unsigned int m = 0; m < scene->mNumMeshes; m++) {
|
||||||
struct aiMesh* assimpMesh = scene->mMeshes[m];
|
struct aiMesh* assimpMesh = scene->mMeshes[m];
|
||||||
ModelMesh* mesh = malloc(sizeof(ModelMesh));
|
ModelMesh* mesh = malloc(sizeof(ModelMesh));
|
||||||
vec_push(&modelData->meshes, mesh);
|
vec_push(&modelData->meshes, mesh);
|
||||||
|
|
||||||
// Faces
|
// Faces
|
||||||
vec_init(&mesh->faces);
|
vec_init(&mesh->faces);
|
||||||
for (int f = 0; f < assimpMesh->mNumFaces; f++) {
|
for (unsigned int f = 0; f < assimpMesh->mNumFaces; f++) {
|
||||||
struct aiFace assimpFace = assimpMesh->mFaces[f];
|
struct aiFace assimpFace = assimpMesh->mFaces[f];
|
||||||
|
|
||||||
// Skip lines and points, polygons are triangulated
|
// Skip lines and points, polygons are triangulated
|
||||||
|
@ -51,7 +51,7 @@ ModelData* lovrModelDataCreate(void* data, int size) {
|
||||||
vec_init(&face.indices);
|
vec_init(&face.indices);
|
||||||
|
|
||||||
// Indices
|
// Indices
|
||||||
for (int i = 0; i < assimpFace.mNumIndices; i++) {
|
for (unsigned int i = 0; i < assimpFace.mNumIndices; i++) {
|
||||||
vec_push(&face.indices, assimpFace.mIndices[i]);
|
vec_push(&face.indices, assimpFace.mIndices[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ ModelData* lovrModelDataCreate(void* data, int size) {
|
||||||
|
|
||||||
// Vertices
|
// Vertices
|
||||||
vec_init(&mesh->vertices);
|
vec_init(&mesh->vertices);
|
||||||
for (int v = 0; v < assimpMesh->mNumVertices; v++) {
|
for (unsigned int v = 0; v < assimpMesh->mNumVertices; v++) {
|
||||||
ModelVertex vertex;
|
ModelVertex vertex;
|
||||||
vertex.x = assimpMesh->mVertices[v].x;
|
vertex.x = assimpMesh->mVertices[v].x;
|
||||||
vertex.y = assimpMesh->mVertices[v].y;
|
vertex.y = assimpMesh->mVertices[v].y;
|
||||||
|
@ -75,7 +75,7 @@ ModelData* lovrModelDataCreate(void* data, int size) {
|
||||||
|
|
||||||
modelData->hasNormals = 1;
|
modelData->hasNormals = 1;
|
||||||
vec_init(&mesh->normals);
|
vec_init(&mesh->normals);
|
||||||
for (int n = 0; n < assimpMesh->mNumVertices; n++) {
|
for (unsigned int n = 0; n < assimpMesh->mNumVertices; n++) {
|
||||||
ModelVertex normal;
|
ModelVertex normal;
|
||||||
normal.x = assimpMesh->mNormals[n].x;
|
normal.x = assimpMesh->mNormals[n].x;
|
||||||
normal.y = assimpMesh->mNormals[n].y;
|
normal.y = assimpMesh->mNormals[n].y;
|
||||||
|
|
Loading…
Reference in New Issue